@nathanrogers Another way to solve this is to keep removing ajdacent pairs of () or [] or {} until convergence. If you end up with the empty string, everything's properly balanced.
warning: solution to the bracket matching challenge; No idea if this will always give correct answers, but it was fun to write and doesn't use explicit-ish loops :D
@ngn yeah, but I couldn't find many improvements to that specific idea. This is what I have now (with the only difference to my APL is the need to remove ⊃¨)
the idea of how it works makes sense to me, just I can't be bothered to start thinking about how to implement all the builtins to have it changeable, and until I just imagined squishing a 3D cube it made no sense how it'd even be a changeable thing
@pierre @AttilaVrabecz a k question for you, guys, this came up a couple of times here in chat: why does +:' (flip each) require a :? +'x creates a list of projections which is hardly ever useful, so why not have ' treat + as unary in this case?
heh an object without a toString function is calling hashCode to make javas default toString, but hashCode is throwing an error with the message "hash not supported for "+this, which is again calling toString :D
what I'm going for is if you get where not open and not closed, merging the lists while inverting one side a←(g open⍳⍵)+-g close⍳⍵ then 2+/a, you should wind up with zero where there is a matching pair
the resulting sum works sometimes to continue with matching pairs of numbers. in the specific example I gave, the result of the first application is this
3 ¯3 5 4 ¯4 ¯5
that looks like I'm on the right track
{g←4|⊢ ⋄ (2+/(g open⍳⍵)+-g close⍳⍵)~0}s
the result of this is 3 ¯3 5 4 ¯4 ¯5 for s←{()}{[()]}{}{}{}{}
It will take me a little time to get used to this, since I am definitely not used to this form of chat, and I'm not sure how much I'll be on, but at least I'm here a bit.
@arcfide Quick intro: use an @ to ping a user. Hover over a msg and click ↳ to ping that message's author while also indicating that you're replying to that specific message (this keeps conversations sane and allows later readers to follow). Use markdown for formatting. Messages beginning with ⎕← are evaluated by Dyalog APL. Enter )about for more info on that.
@Quintec Reading APL is like reading any other natural language. It takes exposure and time to integrate chunking and pattern matching into your workflow so that you can read things quickly, see the patterns, and extract intent and shape from the code.
I'd say one of the biggest problems people have when reading and learning APL is simply that they don't write enough of it.
They also don't spend enough time reading enough of it.
@nathanrogers my idea was separate the levels of parentheses, so the most outer parentheses would be in 1 array, the ones in that in another, and so on. And then it's pretty easy to check that all the arrays have matching parentheses as they're just ()[]{}(){}[]
@nathanrogers There's a big difference between understanding the message conveyed by a single piece of code, and understanding the struggle, machinations, and genius that goes on behind the scenes to eventually construct that single piece of code. One is much harder than the other, and generally opaque unless someone keeps a journal of such thoughts.
@nathanrogers ¯1*⍵ gets the increments of the parentheses levels. +\ then does a cumulative sum, almost getting each parentheses depth (well, negated) with the problem being that all opening parentheses are off by one. That's fixed by ⍵ +
@nathanrogers ⍵=⍵ simply replaces every simple scalar in ⍵ with 1, ≠\ replaces every second 1 of every 1-cell (vector) with 0, then ≡ checks if that's equal to ⍵ [sorry for pings]
> If you happen to see some weird scan (\) in code, and you're a total newbie, it's probably just ngn. Do not fret, ask for explanation by somebody slightly more into APL.