Closed slonik-az closed 3 years ago
Omg you are totally right! I should have tested it better.
The easiest way to implement min with a macro is using nestList So maybe I should look for a better example.
Just sumbitted a PR #48 that fixes the min
macro example code.
Fixed in #48.
The
fusion/astdsl
has a usage example in https://nim-lang.github.io/fusion/src/fusion/astdsl.html for themin
macro that is wrong.How to reproduce
replace the assertion in the example with
Output
The reason being that
min("d", "c", "b", "a")
returns "c" actually.The min algorithm as implemented is wrong. It should not be a sequence of elif branches that stops the first time a smaller element is found. A loop over all the elements is needed to find the minimum.