refactor(sterni/aoc/2022/05): improve _ApplyCmd
* take advantage of block header for destructuring * instead of ModestTake we can split the stack we are picking from into what we need to move and what to keep, saving us from having to repeat ourselves. * remove some unnecessary parens Change-Id: I1b81a93a27d14dcbb6bdd109e862a356f611aca9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7530 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
736edce338
commit
3f2172556a
1 changed files with 3 additions and 4 deletions
|
@ -9,11 +9,10 @@ stacks ← {
|
||||||
|
|
||||||
cmds ← {0‿1‿1-˜ ReadDec¨ ((∧´IsAsciiNum)¨/⊢) (<' ') SplitOn 𝕩}¨ rc
|
cmds ← {0‿1‿1-˜ ReadDec¨ ((∧´IsAsciiNum)¨/⊢) (<' ') SplitOn 𝕩}¨ rc
|
||||||
|
|
||||||
ModestTake ← ↑⍟(<⟜≠)
|
|
||||||
_ApplyCmd ← {
|
_ApplyCmd ← {
|
||||||
c‿f‿t ← 𝕩
|
s Fn _self c‿f‿t :
|
||||||
m ← 𝔽 c ModestTake f⊑𝕨
|
m‿k ← 2↑ c ((≤⟜(↕≠))⊔⊢) f⊑s
|
||||||
(m⊸∾)⌾(t⊸⊑) (c⊸↓)⌾(f⊸⊑)𝕨
|
(Fn m)⊸∾⌾(t⊸⊑) k˙⌾(f⊸⊑) s
|
||||||
}
|
}
|
||||||
|
|
||||||
•Out "day05.1: "∾⊑¨stacks ⌽_ApplyCmd˜´ ⌽ cmds
|
•Out "day05.1: "∾⊑¨stacks ⌽_ApplyCmd˜´ ⌽ cmds
|
||||||
|
|
Loading…
Reference in a new issue