that gives me a bitmask, and I found a number-to-string which then became ⎕VFI but the bit in the middle of getting the number substrings out
i don't know enough to get their indexes, or test if there are two contiguous groups of ones, or just pick out one of the sets and then do a reduce which gets 1280 instead of 1280800
I'm not an APL beginner, but I personally don't like Aaron Hsu's APL style. I prefer a a few tradfns as top-level entry points, they use moderately sized dfns as utilities. The tradfns and dfns in turn use relatively short tacit functions, either given names, or inline. I try to keep my lines doing just one thing at a time, and I try to avoid parentheses, instead opting for naming things with short but descriptive names.
@TessellatingHeckler Oh, it is just that ⎕VFI returns a two element result, the first element is a mask indicating conversion-to-number success and the second is the list of extracted values (with 0 for fails). 2⊃ picks the second element (the values), ignoring the mask, since I know everything must have succeeded due to being all digits.
Ven: and I'm not siding with Aaron yet, but his whole argument (over many talks and online writings) is that readability is often thought of as "an unfamiliar person looks at the code and feels comfortable", but should be thought of as "a familiar person can make a change with confidence that nothing unexpected will happen" - i.e. having a lot of dense code on a page means no surprise black box behaviours from some far away abstracted library call
oh Adam, of course, that's not a left argument to VFI, I see. And iota is just getting the indexes of /any/ bitmask because it only depends on the length of the mask not on the input string, aha
@TessellatingHeckler You should use @ before user names to ping, or alternatively, hover over the right side of a message and click ↳ to insert a tag which marks your message as a response to that message, and pings its author.
@TessellatingHeckler ⍸ is iota underbar, not to be confused with ⍳
does that preferred style include explaining the APL in the comments in English?
if I saw $NoNL = $string -replace "[`r`n]", " " # replace newlines with spaces in PowerShell, I'd say it was a pointless comment, because you can see what the code does by looking at the code
by the time you've written NoNL←'\n' '\r'⎕R' ' ''⍠'Mode' 'D' ⍝ Replace newlines with spaces .. you may as well have written the code once in a more long-hand language ?
👀 but then, it's not all commented like that at all
@TessellatingHeckler I've commented there to explain complex (different from long) APL code that may not be immediately obvious to a moderately experienced APLer. Extensice string concatenation doesn't merit comment. Regex isn't generally familiar to APLers, so I've explained what it does.
the redirected url is missing a / and has a lowercase 'd'
:) a world of strange symbols, where Regex isn't familiar
@Adám iota underbar, ok, that use would clearly clash with monadic iota the way I was picturing it. And I think interval index is what Marshall Lochbaum's talk on nanosecond searching was about, but haven't got to what that does yet. Nevermind. ⍸ will get me a bit further
@TessellatingHeckler Here is another approach: given a Boolean left argument ⊆ will give you a list of areas in the right argument indicated by contiguous 1s in the left argument, removing the elements indicated by 0s altogether:
@Adám left-shoe-underbar partition is exactly what I was imagining for the contiguous 1 thing. I am amazed it's built in, and relatedly how stable the basic APL operators have been for so long
@Adám and no, I paged down the Tweet feed just browsing; but I think it wasn't the first time I hit that redirect bug in the past few months
@TessellatingHeckler video.dyalog.com was replaced by dyalog.tv years ago, and the url redirection to specific videos is an unintended side effect of the redirection technology for the root site.
@TessellatingHeckler Thank you. The basic design is 7 years old now, but I gave it a minor overhaul this winter. Anything in particular you like? Relevant video.
@Adám the sparse clean look without being too gray and basic; the magenta style colour scheme, the sheer convenience of backtick-letter for typing symbols combined with the overlay keyboard showing which keys map to which symbols, the absence of popups about cookies and privacy policies
test if an 'x' is in the string, with a bitvector. Premature optimisation here, but .. is there a way to test if an 'x' is in the string which returns a 0/1 scalar and stops looking after the first match so it doesn't waste time looking at the rest of the string?
@TessellatingHeckler Remember that APL is essentially a better mathematical notation. How would you write that in traditional mathematical notation (TMN)?
@TessellatingHeckler Cool. Regarding the backtick keyboard, do you know about this?
@Adám I did not know about that; the aa<tab> support works, but the backtick-a support doesn't seem to work (in Chrome), nor if I try it as a bookmarklet e.g. here
oh the page describes it as backtick, it⌈ actually apostrophe
@TessellatingHeckler Yeah, I've seen that very odd behaviour on British English Windows 10 Chrome before. I should investigate it, and maybe allow other prefix keys as well.
@Ven ah, that'd be interesting. my concern was mainly compared to this, which by some reason i feel is way cleaner. is it just that I've added more chars?
@Adám idk, light gray is kind of "special" chars - move around, evaluate, change to another layout, etc. blue is, idk, math ops & parens? idk i just did stuff that didn't look horrible and I really wanted that blue there
@dzaima I'd prefer a different set of brackets which won't need that, but keyboarding…
@dzaima In that case, you're not writing a literal array, you're mixing a vector of enclosed arrays, so you should be explicit about that (i.e. second statement there).
Another general language concept to add is default function rank. E.g. we know that monadic ⍳ cannot take an argument of rank above 1, so ⍳ should implicitly mean ⍳⍤1. So too, dyadic ? can only take scalar arguments, so dyadic ? should implicitly mean ?⍤0 0.
Dyadic ⊂ can only take up to rank 1 as left arg, but right arg may have any rank, so dyadic ⊂ should mean ⊂⍤1 ∞
@RewanDemontay APL is a generalisation and harmonisation of traditional mathematical notation (TMN) so it becomes writeable as simple lines of text and machine executable. It can be used for human communication, like TMN, in an execution engine as a fancy calculator, or as a full featured programming language.
@RewanDemontay Because you dropped in, and I didn't recognise your name or avatar. A lot of regulars here started off with zero knowledge of APL, but got hooked…
@Olius You can evaluate a single line of APL by typing it into chat prefixed by ⍞←. Use ⎕← instead for boxed display and multi-line results and use ⋄ instead to silence the first statement. Use ] to call user commands, including ]help ⍣ for help on a glyph etc. Do not use markdown, but fixed-width (4 initial spaces) is fine. Commands: )lb for language bar, )docs for full documentation, )ref for PDF reference card, )idioms for idiom list.
Yep Windows. I've tried all kinds of things, but I couldn't figure out what's wrong. Is there a way to enter APL characters in the Windows interpreter using backticks just like in the RIDE on Mac / Linux?
@Olius I don't use the IME either, as I can't stand Ctrl being hijacked by it. Instead, I've rolled my own real keyboard layout which used AltGr/Right-side Alt as APL key:
@Olius The IME includes backtick input in the interpreter, but since the IME isn't working, that won't work, of course. If you like RIDE, you can use it (with backticks without IME) on Windows too.
@Adám Hi. Yes, just lurking. I don't have much to add to the code golf chatter, but I enjoy following along when I am looking to procrastinate at my day job.
@PaulMansour It isn't just code golf though, we often discuss language design and how to tackle a problem. And then there's the education going on here, of course…
@Adám Don't forget the humor. I just read the Rewan comments above. I have not laughed that hard since Kramer was fired from a job he didn't even have.
According to Rosetta Code, there are two idiomatic ways of creating identity matrix in APL:
1. ID←{∘.=/⍳¨ ⍵ ⍵}
2. ID←{⍵ ⍵ ρ 1, ⍵ρ0}
How does the (2) work? Why is this better than the (1), which uses Outer Product that is considered idiomatic approach in APL?
@Olius ^ is relevant, but your question is slightly different, in that you want the identity matrix corresponding to a given matrix, not generating one of size N.
@Olius Essentially, you are comparing the two coordinates to see if they are equal, as two numbers are equal if 1=≢∘∪ but that's a very roundabout way to check for equality.
@Olius I only modelled it. My model actually relies on a bug in the Dyalog interpreter. We are planning it for version 18.0 (due in the summer of '19), but it requires quite some changes to the interpreters inner workings. Also, it has interesting dilemmas. E.g. is it OK that the right operand function gets called a few extra times? What if it has side effects?
@Olius Yes, but how do we test that it does, and what about side effects of the testing? We're considering adding an internal side-effect-free execution mode.
@Olius No, because that's really what it does. However, as we revisit the subject, we are likely to allow another few primitives to the selective assignment permit.
@Olius You can see the current model. (Code above line 11 is to support ⍫ so it isn't really interesting.)
@Olius As a kid, I learned some German from an introductory APL book. I knew APL, and was able to decipher what the German description had to mean, based on the explained code :-)
@Adám your javascript bookmarklet, regarding the UK keyboard and Chrome; in FireFox the backtick key sends keyCode 192 and in Chrome it sends keyCode 223 That's picked up in your lb.js line 57 the code is also `x.which` and it throws the switch cases out https://github.com/abrudz/lb/blob/master/lb.js#L57
Mozilla says using that is deprecated ( developer.mozilla.org/en-US/docs/Web/Events/keydown ) and that .code "Holds a string that identifies the physical key being pressed. The value is not affected by the current keyboard layout or modifier state"
or .key is a string of a backtick which they recommend
I haven't got as far as trying to fix it, but I'm scared of cross browser and platform issues if I try
ne, mi nur lernas la Esperanton, ĉar la vort-faranta sistemo plaĉas al min
it tries to be regular, composable, and general
@Adám that switch looks like it's checking that ctrl, shift, alt, and metaKey are all off, and only the backtick key is pressed. Is it significant for you that ctrl+backtick should not toggle this bqm mode, for example?
changes ~lines 57, 58, 60 make the switch into an if() {} looking for no metakeys pressed, and inside that looking for one of the characters you suggested, or a tab
(haven't checked if those strings are actually what browsers will see on those keypresses)
@Adám I wonder if it would be possible to unhook the event listeners when the bar is closed; possibly line 46 where "lb.hidden=1" happens in response to the mouse down event.
@TessellatingHeckler No, the idea is that they stay, because the bar may interfere with site content, but you still want the input methods. Also, when you learn the layout by heart, you don't need to see the bar at all.
@TessellatingHeckler No, but on the left you can click the ∇ and then copy the "permalink" target. The last number in it just needs a : prefix to become the appropriate tag. The chat sandbox is useful for experimenting.