Trying to solve a competition problem, I've typed this 'DYALOG'{(⍴⍺)≥⍺⍳⍵}'APL' but on that app it gives me an Length error... (@dzaima And it would be nice to have to possibility to use another keyboard, without those strange primitive; also to be faster, I think).
The only problem on tryAPL that I've noticed is that the language bar disappear after you fill the "Workspace". The solution migth be the APL Keys' keyboard, but a lot of time it does't even open
@ZribiMehdi ⍴ gives the entire shape of the array, which is the length along each axis. ≢ counts the number of major cells (elements of a vector, rows of a matrix, layers of a 3D array, etc.) If what you want is they count, then you should use ≢ to avoid running into issues stemming from having a 1-element vector. While you could take the first element of the shape ⊃⍴ it would give 0 for a scalar (even though it clearly has a single element). ≢ gives 1 for a scalar.
While many APL functions accept 1-element vectors as substitute for scalars, there are also plenty where the difference is maintained.
@ZribiMehdi you can also do :i tryapl in the app to get a Dyalog APL interface through the TryAPL API (of course requires internet). Also, swiping down on the top-left = key will give you your standard OS keyboard, which you can use to enter text
@ZribiMehdi it should be available under the "input languages" button upon opening the "Array Hacker's Keyboard" app (like the 12th item in the list, "English (APL) [en_AL]")
@MasterQuiz yeah, Processing (the thing the app is written in) just doesn't accept unicode chars from the OS keyboard. Can't really do anything about that :/
@Razetime ValidGame, not ValidBoard. Cause I've put vector, correct characters, spare(s) and strike(s) are in the rigth place, bonus length and pair-wise sum
@rak1507 Regex... I've spent a lot of time figuring out how to write '[/X]'⎕R'0'⊢game that I've hated it... Spoiler: After I've discovered that '0'⍨¨@(∊∘'/X')game is faster
@LdBeth what was the type of the elements of the matrix ? The result of ⎕DR matrix will tell you that. And it may be worth increasing the value of MAXWS if you regularly want to run with bigger workspaces. you should edit $HOME/.dyalog/dyalog.dcfg - uncomment the line with MAXWS on it, and change the 256M (the default) to something bigger.
my ValidGame: https://dzaima.github.io/paste/#0dZG9TgJBFIV7nuLGZiFb7I8diVYmvoGhsBl2B5mwzJCZATWAjYYAssTG0oQYTeiVWNngm9wn8e7AklhY7c7uud85584Fy0R6zrocJ0/DCkCEsxXOXjH/xHxThxAwfwFhYMATqzQJJJAS/MvIJ8GJ1/CcoqeMsEJJaCkNnCVtSNqskMfhKc7vcfEtS5htc82h2zcWmhyYhYwzeo9D0CrLDM3gdB3EoyrxcTr3GoFXCw7ThSGTKXiBd2AQEQxPFH0uEEQwLmQVF/Nq5Mvaz1dcw/mEgI5hrBbyCnpcQ0tT9b1lFOLsbZjS5M4Zl89ngI8PcBfRKa2H7uAHmC@365Qem/F2bcpgjgQJk1JZoCyWCVrV7D0KIROWa5ZBT0gDHamSDk8hVdeSjDmFLrJKzD/i8O8uVctVy4r1HHWJd1T24zdWMzd3PPKChkfDBCoWva8o@90m1SPCTlquturudlOjZKvC23e/yw4DrkXr1pkmSmu68n9BUWX8Cw#APL
@dzaima In APL, is it nice to have a lot of guards? Cause also in other problems I've spent some time thinking how to make the function works also for empty vectors or others edge cases
one annoying thing is that APL doesn't lazily evaluate boolean conditions so some of my answers were basically (f∧g∧h) but for efficiency it would need to be {~f ⍵: 0 ⋄ ~g ⍵: 0...}
@MasterQuiz The P7 you've published doesn't match the P7 I have for you.
Did you regenerate it somehow?
Ah, yes, I see, you have P4 with a computed constant, and 2⍴1 instead of 1 1 but that doesn't parse right.
@MasterQuiz You lost a little on P1 (for dividing the Boolean) and P3 for not giving the strictly correct result on the scalar-scalar case. All your other answers were exemplary, except P4 which was good without being exceptional.
@Adám (≢÷⍨100×1⊥∊∘'GC') Was that the best solution to P1? I thougth the other one was better, cause shorter. And I didn't understood in wat case my P3 is wrong?
Yeah, a value judgement. Again, I agree that we could just publish, but some of my colleagues are extra cautious, which I think is laudable, considering the trend in IT these days.
@Adám there are some examples given, those solutions didn't pass even the examples? I can understand not passing some hidden ones (I'm sure mine don't work in general)
Speaking of testing, does a good testing framework exist for dyalog, or is there any good guide on how to test code? Thinking of unit tests specifically.
@rak1507 Control structures for testing, organising positive and negative assertions, with parts that can be switched on for devt or off for production. Automatic logging (that can be turned off) to file etc.
yeah and whereas someone like whitney tries to improve upon APL and make things better, dyalog stick religiously to the original specification for better or for worse
Dyalog computes floating-point +/ in the wrong order, left to right instead of right to left (any plus-reduction with a 1-element result I think). They tried to fix it and had to revert because a client called them out (before my employment so I don't know the details).
Here xpqz.github.io/learnapl/functions.html , @xpqz says that on Ride you must type ]dinput to being able to write a multi-line dfns, but I could write those that without using that command... Am I write or I've lost something?
@Adám Oops, but shouldn't he talks about the experimental mode, I've never found problems with it. It's better than type every time ]dinput and it isn't a complex thing to do...
> The K binary weighs in at about 50Kb. Someone asked about the interpreter source code. A frown flickered across the face of our visitor from Microsoft: what could be interesting about that? “The source is currently 264 lines of C,” said Arthur. I thought I heard a sotto voce “that’s not possible.” Arthur showed us how he had arranged his source code in five files so that he could edit any one of them without scrolling. “Hate scrolling,” he mumbled.
I guess it makes sense now why Whitney wrote K that way
My guess for the rationale is that the "running" value should be the primary input (1st arg in other langs with reduce or fold), but yeah it does feel awkward