How to operation two set that contain structured data.
e.g.
set(set(<a b c>), set(<d e f>)) ⊆ set(set(<a b c>), set(<d e f>), set(<g h i>))#True
set(set(<a b c>), set(<d e f>)) eq set(set(<a b c>), set(<d e f>), set(<g h i>))#false
set(set(<a b c>), set(<d e f>)) ∩ set(set(<a b c>), set(<d e f>), set(<g h i>))#set(<a b c>), set(<d e f>))
Every Raku program should begin with a line similar to use v6;. This line tells the compiler which version of Raku the program expects. For instance, 6.c is an example of a Raku version. Should you accidentally run the file with Perl, you'll get a helpful error message.
A statement ends with a semicolon or a curly brace at the end of a line. In Raku, single line comments start with a single hash character # and extend until the end of the line. Raku also supports multi-line/embedded comments. The compiler doesn't evaluate comments as program text and they're only intended for human readers.
The program takes advantage of this property of Raku's sort to achieve the goal by sorting twice: first by the number of sets won (the secondary criterion), then by the number of matches won (the primary criterion). After the first sorting step, the names are in the order Beth Charlie Dave Ana.
Double quoted strings in Raku can interpolate variables with the $ sigil as well as blocks of code in curly braces. Since any arbitrary Raku code can appear within curly braces, Array s and Hash es may be interpolated by placing them within curly braces.
Regardless of values in a Set
, you can use the eqv
operator to find out if they are the same:
$ raku -e 'say <a b c>.Set eqv <c b a>.Set'
True
$ raku -e 'say <a b c>.Set eqv <d b a>.Set'
False
$ raku -e 'say set(<a b c>.Set,<a b d>.Set) eqv set(<d b a>.Set,<c b a>.Set)'
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With