« first day (979 days earlier)      last day (1972 days later) » 

09:46
Took me embarrassing amount of time to see that you're making pythagorean triples.
⎕←2(⊣+0J1×⊢)4
@RichardPark
2J4
Same number of characters but faster I think
Really nice work @Sherlock9
10:17
@Sherlock9 (⊂0 ¯1)+ should be better, or 0 ¯1∘+¨ if golfing
ngn
ngn
also: ↓0 ¯1+⍤1↑ or ↓0 ¯1+[3]↑
 
2 hours later…
12:08
@Cowsquack used bash to work around it
ngn
ngn
12:20
@Cowsquack another option is [⎕arbout](help.dyalog.com/17.0/Content/Language/System Functions/arbout.htm) but iirc it's deprecated
 
2 hours later…
14:03
@ngn doesn't appear to work, tio.run/##SyzI0U2pTMzJT/…
ngn
ngn
@Cowsquack ('/dev/stdout'⎕ntie¯1)⎕arbout⎕ucs'hello world'
 
5 hours later…
19:02
@Sherlock9 for fun, here's the same thing in my APL. definitely less expressive as it has no complex numbers, but still about the same length (and uses space more efficiently as there are no small arrays)
sadly √-/⌽⍵*2-⍨/⍢(*∘2) is neither shorter, nor does it work as i've yet to define many of the inversions
@RichardPark That should be a primitive, imho:
19:20
@RichardPark Thank you! I'll use your suggestion so I'll be able to generate a large number of triples if needed
@ngn Oh! I'd forgotten about mix and split! That's clever!
Not sure how +⍤1 and +[3] work though, but that's a factor of me not ever finishing the lessons, I think. I've forgotten how ranks work
ngn
ngn
@Sherlock9 matches up 1-cells (vectors) of the left and right arg and applies the function between them
why does APL "read left to right"?
@TessellatingHeckler To be more like English.
@TessellatingHeckler because humans. in math notation, would you read sin(x^2) from right to left or left to right?
English doesn't say "put in the oven the tin full of cake mix made from buttering the tin and combining with the result of stirring the dried fruit into the mixture of milk added to the vanilla added to the eggs whisked into the flower in a bowl"
19:29
Oh that actually answers a question I came here to ask. How do I get a matrix that looks like as follows?
that's so backwards
⎕←↓2 3×⍤1↑⍳6 6
@Sherlock9
┌────┬────┬────┬─────┬─────┬─────┐
│2 3 │2 6 │2 9 │2 12 │2 15 │2 18 │
├────┼────┼────┼─────┼─────┼─────┤
│4 3 │4 6 │4 9 │4 12 │4 15 │4 18 │
├────┼────┼────┼─────┼─────┼─────┤
│6 3 │6 6 │6 9 │6 12 │6 15 │6 18 │
├────┼────┼────┼─────┼─────┼─────┤
│8 3 │8 6 │8 9 │8 12 │8 15 │8 18 │
├────┼────┼────┼─────┼─────┼─────┤
│10 3│10 6│10 9│10 12│10 15│10 18│
├────┼────┼────┼─────┼─────┼─────┤
│12 3│12 6│12 9│12 12│12 15│12 18│
└────┴────┴────┴─────┴─────┴─────┘
With multiples in the "indices" sort of position, but hey there it is
@dzaima math isn't English, it suffers the same problem of the longer it gets, the harder it is to read, because you can't start following it until you've got to the end
19:31
@TessellatingHeckler Then maybe the expression has become too long?
@TessellatingHeckler yeah, for long, parenthesized expressions alternative orderings may make sense, but for 2-3 math ops LTR often is more readable and mappable to code
@Adám is it not-English-like to say "take the first nine integers, square them, reshape them to a 3x3 matrix then sum down the columns" ?
instead of "sum down the columns of (the 3 3 reshape of (the square of (iota 9))))"
@TessellatingHeckler the first 3 parts I'd definitely read as "3x3 reshape of the squares of the first 9 integers", but obviously, with everything to do with humans ever, opinions be opinions
@TessellatingHeckler I'd say no. Those are phrases, artificially hooked together. It is much more natural to ask What is the columnar sum of the three-by-three table of the squares of the first nine integers?
⎕←+⌿×⍨3 3⍴⍳9
19:37
@Sherlock9
66 93 126
Ah. Neat
@Adám where does the idea of "too long" come from, if not "it's hard to read"? I suggest that the other way round seems to require less working memory because of the ability to roll-up the pieces while hearing them, and not have to build up a stack and then backtrack through it
@Adám "natural" vs "artificial", is that not "familiar"vs "unfamiliar", or "common" vs "uncommon"? "Take the first nine integers and square them, then reshape to a 3x3 matrix and perform a columnar sum, and what do you end up with?" sounds natural enough for an example off the top of my head
@TessellatingHeckler How do you (or Microsoft Word!) know when an English sentence has become too long? However, I understand (and share, actually) your concern. I see multiple issues with APL's right-to-left execution, and I'd love to play with a language that stays true to the APL spirit, but is left-to-right.
@TessellatingHeckler if you can't keep the whole expression in your mind, it's too long. i guess LTR kind of serves as a check for that?
RTL? LTR reading?
19:40
@Adám yeah, i meant reading left-to-right
So I have an interesting question. With ⎕IO←1, I was trying to write code that would determine the number of ways to make change for a US dollar with pennies, nickels, and dimes. Why does ≢¯1+⍸100=+/¨↓1 5 10×⍤1↑¯1+⍳3⍴101 take longer to run than ≢¯1+⍸100=+/¨↓1 5 10×⍤1↑¯1+⍳3⍴101. The two scalar additions to the big array?
@TessellatingHeckler Still multiple sentences, strung together. They'd translate to x←⍳9 ⋄ x*←2 ⋄ x⍴⍨←3 3 ⋄ r←+⌿x ⋄ r
@TessellatingHeckler again, that's a preference - I find the LTR reading more natural. (not to say that RTL is unreadable, it too is understandable)
@dzaima I am wondering if there is something in the mathematical background which I don't have, that makes sin(x^2) style easier to reason about, or do symbolic manipulation on, or something
(This does remind me that I should at some point learn how the normal functions work and not just the crazy golfing :P)
19:42
@TessellatingHeckler But for code golf, where solutions tend to be quite long single-expressions, you're absolutely right that APL's order is ill-fitting. See my explained solutions. Most are explained from the right, but sometimes from the left reads nicely.
@TessellatingHeckler It somehow seems ok to write f(g(x)) as f g x by wrong as x f g. However x.f.g is ok, so…
@Adám They are explained from the right, and that's where I start when trying to understand what's happening - the left end happens later, so I can ignore it until later. Are you aware of any left-to-right APL dialect experiments?
@Sherlock9 Nuts, I copied twice. ≢¯1+⍸100=+/¨↓1 5 10×⍤1↑¯1+⍳3⍴101 and ≢⍸116=+/¨↓1 5 10×⍤1↑⍳3⍴101
@TessellatingHeckler Jelly and I, but neither reads (or looks) much like APL.
@Adám ok, I haven't looked at Jelly or other golf-specific languages. I imagine it wouldn't be as simple as mirroring the order of parameters for everything; nuances like 1 2 4 8 having the 8 in first position might be harder to deal with.
CMC: Take one of the medium-long APL code golf answers and rewrite it as "LPA" (pseudo) code.
19:49
@TessellatingHeckler yeah. trying to find where i played around with doing exactly that, but failing currently
"Left Priority Algorithms"
20:02
Oh hey ≢⍸116=+/1 5 10×⍤1↑⍳3⍴101 is even faster
Okay why does 1 5 10×[4]↑⍳3⍴101 work? Particularly the [4] bit
@Sherlock9 ≢⍸+/, though it doesn't seem to affect speed at all
Oh right. Artifacts of when I wanted to see the results too ':D
@dzaima I think I'd have to do +/∊ for that to work
In Dyalog APL, anyway. Not sure how your APL works yet
@Sherlock9 by you've converted the result to a number-only array (and don't convert it back), for which (in any apl) ,
obligatory conversion to dzaima/APL + ⎕VI←1 gives +/,116=+/1 5 10×⍳3⍴101, which is 3x faster than that Dyalog solution (i don't doubt that a properly optimized solution in Dyalog would be massively faster though)
21→19ms with +/,116=+/{(1↑⍵),5 10×1↓⍵}⍳3⍴101. not sure if it's worth making × explicitly be a no-op with 1 as the scalar arg though
20:21
Hm, trying to extend it to the traditional set of pennies, nickels, dimes, quarters, half-dollars, and dollar coins gets me WS FULL on the ⍳6⍴101 part of +/,293=+/1 5 10 25 50 100×⍤1↑⍳6⍴101
Also I have my math wrong
@Sherlock9 well, 101*6 is a big number
Yep
I need to find a smarter way to do this
What's a good way to get the Cartesian product of ⍳100, 5×⍳20, 10×⍳10 etc?
Oh
@dzaima actually with my current model of vectorization i can't, as the vectorizer would have already pre-allocated the output memory
⍳100 20 10 etc
It lives!
⎕←+/,291=+/1 5 10 25 50 100×⍤1↑⍳101 21 11 5 3 2
@Sherlock9
293
20:26
that's bringing dzaima/APL & Dyalog closer now - 52ms vs 30ms
(i probably shouldn't be saying this as a comparison between dzaima/APL & Dyalog as it's more a comparison of my ⎕VI-style thinking vs not, and is a bad built-in in terms of performant array-ish thinking)
as a comparison - just ⍳101 21 11 5 3 2 without ⎕VI is 76ms, compared to 23ms in Dyalog
@Sherlock9 The axis specification is mysterious. For sanity, I'd stay away.

« first day (979 days earlier)      last day (1972 days later) »