Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Haskell

Idiom #68 Create a bitset

Create an object x to store n bits (n being potentially large).

import Data.Bits
x :: Integer
x = sum [bit i | i <- [1..n], wannaset i]
#include <bitset>
std::bitset<n> x;

New implementation...
< >
programming-idioms.org