Open alehander92 opened 6 years ago
Basically we can have
{'a', 'b', @c}
: => a.len == 3 and 'a' in a and 'b' in a and (let c = a - {'a', 'b'}; true)
{'a', 'b', *_}
=> a.len >= 2 and 'a' in a and 'b' in a
All other kinds of checks are forbidden: as some of them are possible, but they'll lead to slower code.
@alehander42
a.len >= 2 and 'a' in a and 'b' in a
Make sure to use a.card
instead of len
for sets. I wish this would be changed to len
for consistency but it doesn't seem likely (https://github.com/nim-lang/Nim/issues/7556).
Maybe you could also make use of <=
for sets.
let a = {1, 2, 3}
let b = {1, 2}
echo b <= a
# -> true, `b` is a subset of `a`
yeah, you're right about card
wow, I didn't know of <=
, a bit strange, but it look like that IN
symbol
{'a', 'b', @c, @e}
max 1 capture in a set, is it useful