Skip to content

Logarithmic counting#17

Open
tobia wants to merge 1 commit intoDanielKeep:masterfrom
tobia:logarithmic-counting
Open

Logarithmic counting#17
tobia wants to merge 1 commit intoDanielKeep:masterfrom
tobia:logarithmic-counting

Conversation

@tobia
Copy link

@tobia tobia commented Jan 13, 2017

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 tobia force-pushed the logarithmic-counting branch from d54ab99 to 2a44a85 Compare January 13, 2017 23:11
@tobia tobia force-pushed the logarithmic-counting branch from 2a44a85 to 343545a Compare January 14, 2017 12:41
@RReverser
Copy link

Wow, this is great idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants