logoalt Hacker News

kelseyfrog • today at 5:04 PM • 1 reply • view on HN

I meant the C++ definition of collatz that would verify the precondition.


Replies

tyromaniac • today at 5:25 PM

I haven't tried it and am afk rn but I'd imagine you just define a constexpr function that implements collatz and use that in your contract.

(Edit: if the input is constexpr itself) Its also quire easy to think about specializing a few templates and doing it that way. If you look up an example of the fib sequence in c++ templates you'll get the general idea.

➕ show 1 reply