Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
type
SquareIndex* = range[0..63]
Bitboard* = set[SquareIndex]
proc test() =
const values = [3, 47, 48, 54, 53, 63]
var b: Bitboard
for f in values:
echo "Card: ", b.card
b.incl(f)
echo "Added ", f
for f in 0..high(SquareIndex):
if f in b:
echo "Value ", f, " found in bitboard"
when isMainModule: test()
Compiled with Nim 0.11.2 under OSX shows the following output:
Card: 0
Added 3
Card: 1
Added 47
Card: 2
Added 48
Card: 2
Added 54
Card: 2
Added 53
Card: 2
Added 63
Value 3 found in bitboard
Value 47 found in bitboard
Value 48 found in bitboard
Value 53 found in bitboard
Value 54 found in bitboard
Value 63 found in bitboard
The cardinality doesn't increase for set values greater than 47. The expected result was to have a final cardinality of six.
With the following example:
Compiled with Nim 0.11.2 under OSX shows the following output:
The cardinality doesn't increase for set values greater than 47. The expected result was to have a final cardinality of six.