View source code
Display the source code in std/uni.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Template std.uni.InversionList.opBinary
Sets support natural syntax for set algebra, namely:
| Operator | Math notation | Description |
|---|---|---|
| & | a ∩ b | intersection |
| | | a ∪ b | union |
| - | a ∖ b | subtraction |
| ~ | a ~ b | symmetric set difference i.e. (a ∪ b) \ (a ∩ b) |
Arguments
template opBinary(string op, U);
Functions
| Function name | Description |
|---|---|
| opBinary |
Example
auto lower = unicode.LowerCase;
auto upper = unicode.UpperCase;
auto ascii = unicode.ASCII;
assert((lower & upper).empty); // no intersection
auto lowerASCII = lower & ascii;
assert(lowerASCII.byCodepoint.equal(iota('a', 'z'+1)));
// throw away all of the lowercase ASCII
assert((ascii - lower).length == 128 - 26);
auto onlyOneOf = lower ~ ascii;
assert(!onlyOneOf['Δ']); // not ASCII and not lowercase
assert(onlyOneOf['$']); // ASCII and not lowercase
assert(!onlyOneOf['a']); // ASCII and lowercase
assert(onlyOneOf['я']); // not ASCII but lowercase
// throw away all cased letters from ASCII
auto noLetters = ascii - (lower | upper);
assert(noLetters.length == 128 - 26*2);
Authors
Dmitry Olshansky