« first day (1559 days earlier)      last day (1090 days later) » 

1:58 AM
I did the swap encoding thing: APL, 32 bytes: {⍵≡∪⍵:⍞←⍵⋄∇⌽@(⍳¯1+c⍳⍞←⊃⍵)⊢c←1↓⍵}
any improvements?
 
2:36 AM
Looks like a good place for . I don't see any immediate golf in vanilla Dyalog
 
 
4 hours later…
7:00 AM
not sure how to improve it with
need to return a character as the intermediate value
maybe do the same thing and then ⊃¨
problem is after ⊢≡∪ it starts reversing everything
 
@Razetime Wouldn't that be ⍢⌽?
 
???
⌽@(⍳¯1+c⍳⍞←⊃⍵) starts reversing the whole string when it finds now matches
not sure why
 
@Adám I think you meant ⌽⍢
 
otherwise I could probably do {⌽@(⍳¯1+c⍳⍞←⊃⍵)⊢c←1↓⍵}⍣≡
 
Reverse under take prefix
 
7:08 AM
Not sure, tbh. I've not looked into the problem at all.
 
though I'm not sure if it will actually save bytes either
 
this is what happens: 26 bytes: {⌽@(⍳¯1+c⍳⍞←⊃⍵)⊢c←1↓⎕←⍵}⍣≡
does @ apply the left function to the entire array when given as the right operand?
 
7:53 AM
@Razetime Working 29 bytes: {⌽@(⍳(≢c)|c⍳⍞←⍵∩⍨⊃⍵)⊢c←1↓⍵}⍣≡
with ⎕IO←0
⍵∩⍨⊃⍵ bit eliminates the trailing space, and (≢c)| fixes the wild reversing problem
 
8:14 AM
huh. interesting
 
 
2 hours later…
10:08 AM
@Bubbler i think I will post this for now
 
 
3 hours later…
RGS
1:05 PM
Hey everyone, just wanted to let you know that approximately every 5 days, a short video on solving a LeetCode problem with APL will be published to this YouTube playlist: youtube.com/playlist?list=PLgTqamKi1MS2b-aKabbnAsnTiQgJAbmnr
2
While I'm starting with the very easy problems from LeetCode, and therefore I do not expect to be teaching you something, you could still enjoy watching them and, more importantly, you might be able to contribute with nice ideas, alternative solutions, etc.
So feel free to interact in the comments and/or PR alternative solutions to the linked repository. ○/
 
1:43 PM
@RGS i like this initiative
 
RGS
@Razetime Glad you like it.
 
would be good to remove the private videos from the playlist
 
RGS
@Razetime Can you show me what you are seeing? I think those might be the ones that are already scheduled to be published.
But I thought YT would be smart enough to understand I only want them there after they have been published.
 
RGS
😂 that looks terrible, yes.
 
1:51 PM
youtube has this premiere option which might be useful for you
 
RGS
Because I own the videos that is not what I see.
@Razetime How so?
 
RGS
That's the thing, those 3 private videos have reveals scheduled, without the extra fluff that the YT Premiere option adds.
Ok, the private videos should be gone from the playlist by now.
@Razetime do you use an old browser or something like that? I'm reading about a feature that was removed from YT not very long ago and I was reading the support forums. Supposedly, you shouldn't be seeing those boxes saying "private video".
@Razetime nevermind, it is something you can toggle on your end. If you click the ... next to the "share playlist" button (both buttons are to the left of the video listing you showed) you can show/hide private videos. But it still looks bad, so I just removed the private videos from the playlist.
Thanks for the heads-up.
 
2:33 PM
interestin
 
 
3 hours later…
5:52 PM
how to create a mask 0 1 1 0 from a string '<ab>' I tried '<ab>' /= '<' v '>' it does not work.. .. how to use logic or. 'v' to connect '<' and '>' ? so that I can have mask 0 1 1 0 ?
 
~'<ab>'∊'<>'
 
@elliptic00 So you want to indicate all characters between < and >?
 
yep
 
@elliptic00 Will you also have inputs like <ab>cde<fg> ?
 
yep, <<abc>><123>44
 
6:02 PM
@elliptic00 Ooh, what exact result do you expect from that case of yours?
 
<<abc>><123> => 001110001110
essentially convert '<' and '>' to 0, else is 1
 
OK, then dzaima's code is right.
 
Nice.. Thanks
'<ab>' /= ('<' v '>') does not work?
why?
 
what would you expect ('<'∨'>') alone to evaluate to?
 
@elliptic00 Because the first thing that happens is '<' v '>' but characters are not in the domain of
(I assume that by /= you mean )
 
6:07 PM
'<ab>' /= '<' work fine
Yep
 
Btw, you logic is wrong, you want different from < AND from > i.e. not
 
yeah, but you can't just do '<' ∨ '>'. That just doesn't make sense
alternatively, see what happens in 3 ≠ (4∨8) - that's "3 not equal to GCD of 4 and 8" (gtg)
 
4v8 GCD of 4 and 8?
 
Yes.
 
oh.. v is logic or?..
 
6:09 PM
Indeed. But extended to GCD for other numbers.
You can write {(⍵≠'<')∧(⍵≠'>')} '<<abc>><123>44' or {(⍵='<')⍱(⍵='>')} '<<abc>><123>44' instead.
Another approach is ∧/'<ab>'∘.≠'<>'
 
('<ab>' /= '<') ^ ('<ab>' /= '>') it works
 
this is where I was trying to get, I think: ((≠∘'<')∧(≠∘'>')) '<ab>' "characters which are not left bracket and characters which are not right bracket", two masks combined
which is then more direct as Dzaima's original "characters which are not in (left bracket, right bracket)"
 
thanks..
how to use 0110 to extract 'ab' out of '<ab>' ?
 
@elliptic00 0 1 1 0/'<ab>'
 
sweet!
 
6:20 PM
However, if that's all you want to do, then try '<ab>'~'<>'
 
nice!
0 1 1 0/'<ab>' is more general
 
Yes, it allows any mask, of course.
 
can we use some unicode outside of APL symbol as a function ?
function name
 
Some accented characters and and but nothing else.
See documentation here.
 
any simple to check string '<{ab}>{123}>' contains balanced brackets: bracket => {}<>
'<{ab>}' is not balanced
 
6:32 PM
@elliptic00 One approach is repeated regex: ~∨/'<>{}'∊⍨'{[^<>{}]*}|<[^<>{}]*>'⎕R''⍣≡string
@user4069 Welcome back!
 
6:46 PM
oh.. nice.. never know APL can use regex
but regex can not use any deep of bracket.... I expect stack to solve it..
 
I'm not sure what you mean by regex can not use any deep of bracket.
 
use Stack to solve it..
like. '<{<ab}>}' regex is not easy to know whether the string is balanced or not.
above string is NOT balanced..
 
@elliptic00 Right, which is why ~∨/'<>{}'∊⍨'{[^<>{}]*}|<[^<>{}]*>'⎕R''⍣≡'<{<ab}>}' gives 0.
 
regex is only good for static string... but stack is more general to solve balance bracket problem
 
Ooh, @Marshall is here. He'll have what to say about balanced brackets…
@elliptic00 I'm still not sure what you have in mind. Give me a string you think my solution will fail on.
 
6:55 PM
the problem is you have to hard-code all the bracket pairs. What if you you had 100 matching bracket pairs?
 
It'd still work. You'd just extend the left operand accordingly.
 
but you'd have a horrible horrible horrible regex
 
¯\_(⍨)_/¯ it can be machine genrated.
Performance may suffer eventually, though.
 
@Adám that's 1) still just stupid; 2) will be extremely slow; 3) isn't even APLy; 4) probably harder to do than an iterative stack-based solution
 
Yup.
 
6:58 PM
Well here's the bracket matching code from my compiler (handles (){}⟨⟩ for BQN but it's fully general).
I still don't have a good method for finding which brackets are missing though. The current method often gives up when it doesn't have to.
 
theoretically point of view. regex is can ONLY solve "regular language" which is regular expression, bracket balancing is BNF so regex can NOT solve them
 
well here it's repeated regex, and i think infinitely repeated regex is maybe turing complete?
 
@elliptic00 I believe repeated application of regex can determine if the brackets are balanced or not. Also, modern regex isn't regular.
 
regardless, regex is not what you want to use for matching arbitrary brackets..
 
Of course. Still is fun though:
       Balanced←{Esc←'\W'⎕R'\\&' ⋄ ~∨/((⍺∘{(Esc⊃⍵),'[^',(Esc∊⍺),']*',(Esc⊃⌽⍵)}¨⍺)⎕R''⍣≡⍵)∊∊⍺}
       '[]' '()' Balanced '([ab])'
1
       '[]' '()' Balanced '([ab)]'
0
 
7:08 PM
not what I'd show as the APL solution for matching brackets though :|
 
So this is an extracted version of the BQN code: the function returns 1 for a balanced argument and 0 for an unbalanced one. Completely flat, no loops. Could probably be shortened a little if all you want to do is check whether things are balanced.
 
That looks translatable.
 
 
4 hours later…
11:11 PM
I return
 

« first day (1559 days earlier)      last day (1090 days later) »