tlborm icon indicating copy to clipboard operation
tlborm copied to clipboard

Logarithmic counting

Open tobia opened this issue 9 years ago • 1 comments

Here's an efficient counting macro I came up with while reading the chapter on Counting.

It can count a practically unlimited number of tokens with Rust's default recursion limit, it's faster than Slice length, and it produces a constant number.

I assert_eq'ed it on all numbers from 0 to 50, just to be on the safe side.

Enjoy!

tobia avatar Jan 13 '17 23:01 tobia

Wow, this is great idea!

RReverser avatar Jan 15 '18 19:01 RReverser