It seems like project euler would be perfect fodder for APL, but the thing is I'm trying to learn APL and I'm not a mathematician, so having to learn forms of math I've never heard of and APL at the same time, I never know what I should be doing
getting rather impatient
the irritating point is that direct solutions are often horrible as to be impossible to solve simply
@nathanrogers see, your code requires backtracking - the first time reading trough I don't have a clue of what a is. Bubblers train on the other hand is a simple "floor and argument minus floor"
@nathanrogers and, as I've said again and again, trains shouldn't just blindly be applied, there are cases when a dfn is better.
but IMO Bubblers train is way nicer than "the variable 'a' and omega minus a, where a is floor of omega". You yourself said way too many times thwt retracing is horrible, and you yourself wrote a function that needs retracing..
(and, unrelatedly, that can also be written as 0 1∘⊤)
@nathanrogers dzaima has already answered, but also note that ⍵-⌊⍵ is the fractional part, which is the division remainder when divided by 1, so ⌊,1∘| works as well.
@nathanrogers diceFreq←(⊣,∘⊂'*'⍴⍨⊢∘≢)⌸⍨∘∊+/¨∘⍳ which is an excellent example of when not to go tacit.
@Adám for the inner function buitins for {⍺⍺ ⍵} and {⍺ ⍵} would make that a nicer expression, but a dfn would still be better (though it'd too benefit from {⍺ ⍵}!)
@dzaima {⍺⍺ ⍵} is ignore-left-and apply-monadically? I've thought about that. Yes, I agree that a single-char {⍺⍵} would be very valuable. ⍮ seems like a nice symbol…
as I was typing that I too thought of ; underbar but my phones keyboard doesn't have it :/ I'll definitely think (again) about adding the two to my APL when home
I don't like trains (perhaps because I not understand that) I like instead a {f} z because I can insert a and z in f where I want... one extension of that will be a b c ...{f} d e... where one can see where in the expression f goes exactly a,b,c,...d ea... but this in Apl is impossible because it is seen as 2 array...
I think it is very helpful to have a good naming convention. I keep all variables dromedaryCase and all functions CamelCase. I use descriptive names, and try to keep variables as nouns and functions as verbs. If possible, I prefer that monadic operators are adverbs, and dyadic operators should be prepositions.
it is possible doing all in Apl but the problem remain how make all readable as one read a novel? Yes good names for function and operator should be ok; primitive just one symbol should be ok if few; but something is difficult to read because is difficult operations and algorithm
@dzaima Yeah, but that doesn't have a huge effect, and one you learn the idioms ⍤⊣ and ⍤⊢ I think that'll be sufficient. A much bigger issue is dealing with runs of monadic functions inside trains, especially if some of them are reductions.
@dzaima f⍤⊣ is certainly understandable just from the primitives' definitions, but a reader of tacit APL will quickly learn to recognise this phrase and start reading it as a whole.
@DyalogAPL Maybe you should add ⇤ as cap if its anomalousness doesn't bother you.
On the other hand, an inline dfn has very little overhead for a long row of monadic applications, and it nicely delimits the run while declaring which argument it uses on its far right side. You can use that as a kind of quoting mechanism inside a bigger train.
In our latest blog post Marshall looks at a cool technique - added in Dyalog 17.0 - called “tolerated comparison” You can read part 1 here https://www.dyalog.com/blog/2018/11/tolerated-comparison-part-1/
⌺ (not updated on TIO yet) now handles all array sizes, extends its` ⍵⍵` and allows you to specify how you want edges (along each dimension separately, if you want) treated: zero, replicate, mirror, reverse, wrap. It also allows twisting.
oh this also is a thing.. yeaah the reshape business is hard
that specifically is a DoubleArr instance with shape ⍬ and a single number in it. When getting converted to a HArr for the printing (because why would i optimize the repl printing) it gets converted to a HArr of shape ⍬, with a single Num in it.
if I made a DoubleArr of shape ⍬ be equal to a scalar number always it'd make it much harder to switch to an APL where 1 ≢ ⊂1, checking out which is still on my todo list.
I wish I could tell IDEA to scream this at me every time I use Value.ofShape :p
I've also added ⊇[k] so you can select the first and third columns with 1 3⊇[2]A
@dzaima Sure, and you can omit axes too. / replicates the trailing axes, and ⌿ replicates leading axes.
You can also skip axes with a scalar 1
And then I've added extensions so ⍳ and all comparison functions work on characters too.
I'm currently working on the spec for a system function to manipulate datetimes, e.g. 100∘+⍢⎕T ⎕TS means 100 days from now, but this work is for the real product, not for my extended playground.
@dzaima It converts dates to a float number of days before/after an origin, so you can do calculations. It can also convert dates to human-readable text in various languages
@nathanrogers Yup, looks good. However, to be precise, the problem calls for a monadic function, no? so you can either ∘ the right arg, or just inline it and put ⍵ instead of your current ⍺s.
how'd you go about implementing 'hi' 2 'bye'[2] not returning an enclosed 2? That either requires checking whether the picked items are all the same type and handling the scalarization in the resulting object, or checking if the pick returns a scalar
@ngn I just feel like handling special-cases in a global "please fix my mistakes" function is stupid
I even don't really like the fact that I have squeeze at all actually
i wonder how much would break if i made squeeze not recurse down the whole array (i.e. short-circuit return if from the checked items a simple DoubleArr/ChrArr can't be made) and asked the caller to do that only if it's necessary
@dzaima that's just my attempt to summarize Jim Brown's paper, which is more concerned with the mathematical side of the array model than its practical implementation
@dzaima i can't really compare, as i've only used the 1≡⊂1 model, but it seems to me that with 1≢⊂1 you'd be forced to use a lot more ⊃ for simple operations
I remember being very confused about why +/(1 2)(3 4) returned an enclosed result because +/1 2 3 didn't. +/1 2 3 not returning an enclosed result feels special-casey to me
^ another reason for my APLs f/vec automatically disclosing the result
I don't understand why you see it as auto disclosing. I would just see it as not enclosing in the first place. There isn't really a good reason for it to be enclosed.
@H.PWiz the good reason for f/vec returning an enclosed result is consistency among dimensions. I didn't think that was worth it. (but yeah, I think of it that way too, just that the people here are more used to Dyalog APL than mine :p)
@H.PWiz isn't it strange how in this the last line suddenly hops to 5 6, not logically stay at ⍬? (i know i'm arguing against my own decisions, but whatever :p)