From 1a9c7020e561a52c5b764dcf5abd5f25177db2c9 Mon Sep 17 00:00:00 2001 From: flaviut Date: Sun, 13 Jul 2014 16:53:34 -0400 Subject: [PATCH] Begin work on bitsets --- content/bitsets.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/content/bitsets.md b/content/bitsets.md index e69de29..ad28b03 100644 --- a/content/bitsets.md +++ b/content/bitsets.md @@ -0,0 +1,19 @@ +--- +title: Bitsets +--- + +# Bitsets + +Nimrod comes with a built in way to build a set of ordinal types. The requirements for a type to be usable inside a bitset is that it must be an ordinal and «\texttt{high(T)} < 2^{15}». + +|Operator | Operation | Example Code | +|-------------|-------------------------------|----------------------------------------------| +| `A in B` | is A an element of B? | `'d' in {'a'..'z'}` | +| `A notin B` | is A not an element of B? | `40 notin {2..20} ` | +| `A + B` | union of A with B | `{'a'..'m'} + {'n'..'z'} == {'a'..'z'}` | +| `A * B` | intersection of A with B | `{'a'..'m'} * {'c'..'z} == {'c'..'m'}` | +| `A - B` | relative complement of A in B | `{'a'..'z'} - {'b'..'d'} == {'a', 'e'..'z'}` | +| `A <= B` | is A a subset of B? | `{'a'..'c'} <= {'a'..'z'}` | +| `A < B` | is A a strict subset of B? | `{'b'..'c'} < {'a'..'z'}` | +| `A + b` | add element b to set A | `{'b'..'z'} + 'a' == {'a'..'z'}` | +| `A - b` | remove element b from set A | `{'a'..'z'} - 'a' == {'b'..'z'}` | \ No newline at end of file