<@U3E25GSEP> And I think you can replace `claims.m...
# advent-of-code
k
@robin And I think you can replace
claims.map { it.cells }.reduce { ... }
with
claims.flatMap { }
.
r
Oh wow, you're right! I use flatMap so often I'm surprised I didn't think of that 😄 It even speeds up my solution almost 2x
k
And other suggestion (but maybe you just prefer it this way)
x..(y-1)
is
x until y
.
r
Right! I added the
-1
later when I realized I had an off-by-one, so didn't think to switch to
until
k
Idea should have a warning for this 😉
r
It does! It just doesn't seem to get triggered if the second argument is in parens 😄
k
I don't even want to know what the code for inspections looks like if parenthesis break it.
r
Probably works on the AST, and just evaluates the top-level expression that makes up the righthand operator, und doesn't evaluate subexpressions for performance reasons or something like that. Although allowing parenthesis around it seems trivial
k
But why are parentheses part of the AST 🙁
r
Because it's the Abstract Syntax Tree, and parens are part of the language syntax 🤷
k
Well it's also the Abstract Syntax Tree 🧌
Haha I remember reading this on wikipedia:
The syntax is "abstract" in the sense that it does not represent every detail appearing in the real syntax, but rather just the structural, content-related details. For instance, grouping parentheses are implicit in the tree structure [...]
Maybe it's different for an IDE because it actually needs to know about them.
r
Yeah, there are also inspections like "remove unnecessary parenthesis" so IntelliJ definitely needs to know about them in the source representation it uses for inspections. Maybe that's a separate stage before the AST though, no idea.