« first day (823 days earlier)      last day (1832 days later) » 

8:50 AM
@ngn it wasn't for golfing, but .. why not? I was picking up on people here saying "each" is more imperative and less array focused, and challenging myself to rewrite it
using -2 rank-0 take, I see what it's doing; I really need to study rank and shape, I'm getting stuck there a lot
what on earth is it that Rho returns? `n←1 2 3 4 5` is a vector.
`⍴n` shape 5
5
the 2 5 reshape works
2(5)⍴n
1 2 3 4 5
1 2 3 4 5
the 2(shape)reshape doesn't
2(⍴n)⍴n
DOMAIN ERROR
so it must return a nested vector or something?
tally of rho n, shape of rho n, depth of rho n, all 1
ok forget all that, I've just thought to ask what the shape of a scalar is, and they don't have any
 
9:35 AM
@TessellatingHeckler Markdown doesn't work in multi-line messages, but if you write multiple messages, the interface will merge them visually.
@TessellatingHeckler The shape of a scalar is as it doesn't have any dimensions.
 
10:07 AM
@Adám ok to both those 👍
Is there a way to promote a thing to have +1 dimensions?
 
@TessellatingHeckler Yes, but where do you want the additional dimension?
 
I don't know that I can answer that.
    a←1 2 3 ⋄ b←4 5 6 ⋄ 2 3 ⍴ a,b
this makes a 2 3 matrix, but it feels laborious
a←1 2 3 ⋄ b←4 5 6 ⋄ (1 3⍴a)⍪b
 
⋄ a←1 2 3 ⋄ b←4 5 6 ⋄ ⎕←c←↑a b ⋄ ⎕←--- ⋄ ⎕←⍴c
 
this, making a into a matrix but with only one *row, feels nicer
 
@Adám
1 2 3
4 5 6
┌─┼─┐
- - -
2 3
 
10:10 AM
In general, you can insert a 1 in front of the shape vector of A using ↑,⊂A.
(If you use my Extended APL, that'd be just ↑⍮ doing exactly the same.)
@TessellatingHeckler Btw, you could also write ⍉⍪a for a vector-to-one-row-matrix conversion:
 
hmm, NARS2000 doesn't use uparrow and downarrow for mix and split, does it?
 
⋄ a←1 2 3 ⋄ b←4 5 6 ⋄ ⎕←a⍪⍉⍪b
 
@Adám
1 2 3
4 5 6
 
@Adám oh interesting; I did find a way to table them and then transpose
 
@TessellatingHeckler It has the monadic and exchanged, so mix is and first is .
@TessellatingHeckler Yeah, you could merge them first too, and then transpose:
⋄ a←1 2 3 ⋄ b←4 5 6 ⋄ ⎕←⍉a,⍪b
 
10:15 AM
@Adám
1 2 3
4 5 6
 
@Adám monadic right shoe, toolbar hint says "Disclose", which I imagine as being the opposite of box, but .. it does work as mix
@Adám what is that general approach doing; up arrow, catenate, box? Is one or more of those an operator?
 
@TessellatingHeckler Yeah, NARS's names and symbol choices (they stem from APL2s) are confusing, imho.
@TessellatingHeckler It encloses the entire array, then makes it into a vector of length one, then trades the outermost level of depth (i.e. the one-element vector of something) for increased outer rank, i.e. a leading axis of length 1.
 
10:29 AM
@Adám comma is monadic ravel in this case, which I would have guessed to do nothing on a box, but apparently does something subtle. Trying things, I see the shape of a box is Zilde, so it's a scalar. Ravel seems to unroll all dimensions into a vector, but not change nesting, compared to monadic enlist which seems to completely flatten
@Adám "trades the outermost level of depth for increased outer rank" - I can't quite follow; is that a description of what mix does generally, or what mix is being used to do in this situation?
 
@TessellatingHeckler Monadic , ravels the elements into a vector, but any nested elements stay. A scalar (nested or not) becomes a 1-element vector. is simply an empty numeric vector, i.e. ⍬≡0⍴0
@TessellatingHeckler What it does generally (and here, of course).
It is maybe easier to understand what ↑A does by looking at what ↓A does:
⎕←↓3 4⍴⍳12
 
@Adám
┌───────┬───────┬──────────┐
│1 2 3 4│5 6 7 8│9 10 11 12│
└───────┴───────┴──────────┘
 
It splits the major cells into elements of a vector. re-assembles the original array.
Anyway, gotta board my plane
 
@Adám Thank you :) Safe flight!
 
@TessellatingHeckler Thanks. Don't be afraid of experimenting!
Meh, then line of people boarding continues around the corner. Not worth it…
 
 
1 hour later…
11:55 AM
0
Q: Loading APL script from GNU APL session

August KarlstromIn GNU APL, is there a way to load an APL script (text file) from a running APL session?

 
 
1 hour later…
1:10 PM
@TessellatingHeckler what helped me out of that problem was a function that showed the shapes trough all the depths. e.g. ⊂1 2⍴⊂⍳3[|1 2|3]. examples with it
visually what is it removes the first |, and inserts a | before the last number in the first group
 
1:23 PM
@TessellatingHeckler @dzaima There's also displayr from dfns which shows dimension lengths along the top and left sides, and depth in the lower right corner:
⎕←displayr ⊂1 2⍴⊂1 1 2⍴⍳2 ⊣ ⎕CY'dfns'
 
@Adám
┌─────────────────────┐
│ ┌2────────────────┐ │
│ 1 ┌┌2───┐ ┌┌2───┐ │ │
│ │ 11 1 2│ 11 1 2│ │ │
│ │ └└~───┘ └└~───┘ │ │
│ └2────────────────┘ │
└3────────────────────┘
 
The outermost box is a scalar (no dimension lengths in top left corner) of depth 3, containing a 1-row (left border 1) 2-column (top border 2) matrix of depth 2 (bottom left 2) which has two identical elements, both being a 1-by-1-by-2 numeric (~) arrays of the numbers 1 2.
 
@Adám both have good uses - displayr displays more structure while my fds gives just the shapes linearly and no extraneous data
e.g. for the case of , displayr, imo shows the transformations way worse than fds
 
1:39 PM
@dzaima Fun exercise: Function that, given an array, gives a complete English description of it. E.g. ⊂1 2⍴⊂1 1 2⍴⍳2 gives Scalar containing a 1-row 2-column matrix containing [a 1-layer 1-row 2-column array containing the numbers 1 and 2] and [a 1-layer 1-row 2-column array containing the numbers 1 and 2].
@dzaima Maybe. I find displayr very clear: you see depth decrease from 3 to 2 to 1 () while additional axes (of length 2) are appearing.
 
@Adám the shapes 1 2 nor 1 1 2 in your example are displayed in a straight line, and imo ...||... is a way clearer way to show a scalar than an empty border
 
@dzaima True. Maybe it just makes me nervous that your function looses info on irregular structure, and of course the actual data.
 
@Adám different uses may require different representations. it may be useful to make the function error on irregular data but that'd make 1 2⍴⊂3 4⍴⊂'foo bar' 'baz' error even though it'd be helpful to at least see [1 2|3 4|3. but the displayr output of that is just useless for me
also big tables - if i have a 10000 row table, I definitely don't want to see the data white trying to figure out what mix of and arrows do i need to do before a
 
@dzaima Yeah, I agree. Maybe something like displayr that don't show that data, only the axes' lengths.
 
@dzaima hmm well cutting off at the place of irregularity like that is also an option
 
 
3 hours later…
4:33 PM
Why exactly does this test case fail: Try it online!. I'm assuming it's a precision issue but I don't see exactly how it hapening. Context is this problem
Note: All other test cases are passing.
 
ngn
4:58 PM
@Jonah how does that work? it uses ln(x)*y instead of x^y?
note that x^y is equivalent to exp(ln(x)*y), not just ln(x)*y
 
5:32 PM
@ngn Correct. It still works though bc a^b < c^d <==> b*ln(a) < d*ln(c). And we're only interested in comparing the two expressions.
 
ngn
@Jonah but then you use ln(x)*y as the exponent in the next step
and ln(x)*ln(y)*z is not equivalent to x^(y^z)
 
so you're saying the whole approach is just wrong? is it just coincidental that it works in all the other cases?
 
ngn
@Jonah i think so
so many downvotes for such a nice problem
 
downvoted bc it's a slight variation of the same problem with 3 elms. i think it's different enough to be new though, since it requires a different approach.
 
ngn
@Jonah i agree
 
5:43 PM
 x^(y^z) < a^(b^c)
 y^z ln(x) < b^c ln(a)
 z*ln(y) + ln(x) < c*ln(b) + ln(a)
that should be valid, correct? (each line is an iff)
 
ngn
@Jonah shouldn't it be ln(ln(x)) and ln(ln(a)) in the last line?
 
@ngn yep, it should
thanks
 
ngn
6:01 PM
i keep getting wrong results for that test case, even after trying to solve it "correctly" in different ways
 
@ngn interesting. could it be precision? (fwiw, i verified on wolfram alpha that the test case is correct)
 
ngn
pari/gp confirms it too:
? log(2)*(2^2^2^3) > log(10)*(4^3^2^2)
%1 = 1
 
did you try with the identity produced from the same transformation i did above but for 5 elms and taking ln 4 times?
 
ngn
@Jonah that can't work because of the 1s
ln(ln(1)) is undefined
i tried folding both sequences together and normalizing (i.e. dividing both numbers by the larger of them) after each step
⎕←{>/⊃{r÷⌈/r←⍺*⍵}/⍵}2 2 2 2 3,¨10 4 3 2 2
 
Interesting. I was expecting this to be much easier. I'll take a look tonight, need to take off for a bit.
 
ngn
6:14 PM
my approach is probably wrong...
 

« first day (823 days earlier)      last day (1832 days later) »