« first day (2353 days earlier)      last day (308 days later) » 

7:29 AM
It's so nice that normalizing a vector just is {÷∘(+/)⍨⍵}
 
@Schiphol Why wrap it in a dfn? ÷∘(+/)⍨ and (⊢÷+/) both work.
 
I guess that's me thinking in terms of norm ← {÷∘(+/)⍨⍵} so that I can then apply norm to whatever. But that's not the usual apl workflow, right? You just write the sequence of glyphs you need, as needed
 
You can still do norm←÷∘+/⍨ and apply that later. Same with norm←⊢÷+/
 
right. That's a tacit function, correct? I need to read a bit more about that
 
Correct. But note that you were already using a tacit function, just wrapped in a dfn.
 
7:38 AM
@Schiphol Don't you want Euclidean length: (⊢÷0.5*⍨+/⍤×⍨)?
 
@Adám I see, my dfn had a tacit function inside because there were various operators (?) chained without intervening variables?
@B.Wilson I'm sure I'll need that at some point :)
 
@Schiphol You created a new function using operators.
 
@Adám here you would still need the parens around plus reduce, right? edit: huh, only in the first one but not the second
 
Yes, my bad. Because operators have short right scope. However, ⊢÷+/ doesn't use any (explicit) operators, so it doesn't have the issue.
 
I'm confused by right tack here. It's not just doing same, is it?
(I'm confused by right tack in general, tbh)
 
7:48 AM
It is just that, always equivalent to {⍵}
 
then why have it? Why is ÷+/ not the same thing?
 
⊢÷+/ is a fork: (f g h)Y is (f Y)g(h Y) so (⊢÷+/)Y is (⊢Y)÷(+/Y) which is Y÷+/Y
 
oooh it's "same" of whatever happens to the right of the whole train of operators? (Sorry if I'm misusing the terminology)
 
Yes, just like +/ is the sum of the argument, is the identity of the argument.
 
gotcha
 
7:50 AM
The most famous 3-train is +⌿÷≢ — can you see what it does?
 
the mean?
 
Correct.
Another neat one is ≠⊆⊢ which is used dyadically, usually with a space character on the left and a character vector on the right.
 
because you are using reduce first does this mean that when applied to an array it would take means column-wise?
 
Yes, that's right (well, "matrix", not "array").
 
sorry, matrix
 
7:52 AM
also counts the number of rows of a matrix. If we wrote +/÷≢ it'd give a meaningless result on a matrix.
 
right
 
Dyadic +,- is cool too.
 
+/÷(⍉≢) something like this would be the row-wise means?
 
It'd need to be ≢⍉ yes, although that's a bit wasteful.
+/÷2⊃⍴ would work.
 
@Adám I'm not immediately seeing what this does. Not concatenate the sums and the differences?
 
7:55 AM
Note how this is a 5-train, which is just a 3-train where the right-side tine of the fork is itself a 3-train: +/÷(2⊃⍴)
@Schiphol Yes, denoted ± in traditional mathematical notation.
 
oh, i see!
 
As you can see from the 2⊃⍴ the left-side tine of a fork can be a constant, which just works as a constant function. It is in fact very common to have constants there.
E.g. you can check if an array is empty with empty←0∊⍴ or if it is a scalar with ⍬≡⍴
You can check if the arguments are co-prime with 1=∨ or get the inclusive difference with 1+-
 
@Adám I'm still trying to parse this. Doesn't it mean (2 ⍵) ⊂(⍴ ⍵) or something like that?
I see that you are taking the second element in the ⍴ vector, but I'm not sure how
 
8:12 AM
@Schiphol 2 acts as a constant function here, so it consumes the and "returns" 2.
 
yes, but 2 "applied" to, say, 3 4 does not result in 4. You'd need to throw in a squad for that
 
(index) or (pick), yes.
(you had a typo with instead of )
 
oh, sorry, it's been a combination of typos and general incompetence, I see that now!
thanks so much for your time, Adám, this is so helpful
 
Any time!
 
8:48 AM
@Schiphol Nice! You're leveling up :D I think I was having the same kind of conversations with Adám a year or so ago. Hope you're having fun!
 
I'm having lots of fun :) Currently also doing the problems in the APL competition, which is helping me a lot to fix ideas
 
 
4 hours later…
 
4 hours later…
5:11 PM
My solution to the APL problem solving contest 1:8 is just terrible. Looking forward to the contest being over so that I can ask how on Earth to improve it. I'm currently drunk on forks.
 
5:49 PM
I think 1:8 has some amount of ugliness you can't really deal with
 
OK, good to know. It's def ugly
 
6:04 PM
I should perhaps explicitly disown the implication that my other solutions are not ugly :)
 
6:19 PM
I'm kinda happy that I used something new (for me) -- outer product, in this case -- to solve a self-imposed problem
It's probably ugly and not idiomatic, but I created {(⍵?≢r)⌷⍨∘⊂⍨r←,(⌽6↑⎕A)∘.,('-' '' '+')}
It randomly generates ⍵ grades from F- to A+
As I said, self-imposed problem and likely bad solution, but it's a little something that feels like progression in my learning
Is there a more idiomatic way of doing that?
 
7:18 PM
@AndréLeria Without duplicates, that is.
 
Duplicates?
 
Yes, you give the function a number as argument, and it'll return that many grades, but no two grades will ever be the same. The maximum is 18, which generates a random order of all possible grades.
It is because of ⍵?≢r which uses dyadic ? (deal). If you want independent values, use ?⍵⍴≢r which uses monadic ? (roll).
@AndréLeria If you allow duplicates: {⎕A[?⍵⍴6],¨'-' '' '+'[?⍵⍴3]}
 
Oh, I wasn't aware of that
I see, your solution randomly picks a letter and a modifier instead of making a list of all combinations beforehand
Smarter
I understand I don't "think in arrays" very well yet
 
But for no-duplicates, your solution is pretty much as good as it gets. You have an unnecessary and you don't need the right-most parenthesis. You also already know that ≢r is 18, so no need to compute that. Finally, you can "unpack" your derived selection function {(⊂⍵?18)⌷,(6↑⎕A)∘.,'-' '' '+'} or just use brackets {(,(6↑⎕A)∘.,'-' '' '+')[⍵?18]}
@AndréLeria Not sure. It might be faster to use your approach. For allowing duplicates, that'd be {(⊂?⍵⍴18)⌷,(6↑⎕A)∘.,'-' '' '+'} or {(,(6↑⎕A)∘.,'-' '' '+')[?⍵⍴18]}
 
Oh, yeah, the ⌽ was reminiscent of an earlier test which I forgot to remove
 
7:34 PM
Right, pre-computing all the possibilities, then selecting random ones from that is much faster:
      Q2←{⎕A[?⍵⍴6],¨'-' '' '+'[?⍵⍴3]}
      Q1←{(⊂?⍵⍴18)⌷,(6↑⎕A)∘.,'-' '' '+'}
      'cmpx'⎕CY'dfns'
      cmpx 'Q2 1e6' 'Q1 1E6'
  Q2 1e6 → 1.6E¯1 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
* Q1 1E6 → 2.1E¯2 | -87% ⎕⎕⎕⎕⎕
 
The idea of computing 18 was because I used ⍺ in an earlier version, so... yeah, I need to clean up better
 
This is a very nice example problem. Well done!
 
Thanks
And thanks again for all the analysis
It's honestly amazing to me how fast you think of all these variances
 
You know you can post things like this on Code Review, right?
 
Hmmm, I didn't think of that
 
7:36 PM
what's code review?
 
 
thanks, I wasn't aware of that SE site
Problem 1:10 of the competition is... not even funny
 

« first day (2353 days earlier)      last day (308 days later) »