Zulip Chat Archive
Stream: metaprogramming / tactics
Topic: WFTactics
namibj (Jan 22 2024 at 14:44):
I have a recursive definition that normalizes a Option (List α)
where α
is a tagged enum carrying a Nat
.
I sort the list using a lexicographic order (with first by variant, then by value), then if the first variant-many contain the variants terminate out, otherwise prepend the first missing variant with a 0
value before recursing.
In all other cases (detecting a variant twice in a row while iteratively matching for the sequence is all variants; Option.none
), I terminate with Option.none
.
Clearly this can grow the list at most variant-count-many times before terminating the recursion.
I'd love a tactic (or an extension to WFTactics) that can deal with this "will grow only constant many times before terminating out".
I'll provide the github later (not cleaned up yet, need to check licensing before uploading); it happened during my AoC2023 Day01 Part1 solution.
A band-aid was to slap partial
on it, but that's both ugly and will prevent me from using proof-based programming for Part2.
AoC 2023 Day02 solution
Oh, and yes, of course, I'm aware that AoC is just an exercise.
But last year it has shown itself to be a good exercise for me learning applied Futhark on AoC 2022. E.g., I managed to write an implementation for AoC 2022 Day5: crate stacker that processes the lines in parallel. Not because that's a good approach here, but because a language targeting GPUs and GPU-like processors is to be used for parallel implementations, so I ought to learn how to write parallel code even when it's not easy to.
Last updated: May 02 2025 at 03:31 UTC