Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How compare set of set in raku-lang?

Tags:

set

raku

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>))
like image 372
黃家億 Avatar asked Jan 15 '20 13:01

黃家億


People also ask

How do I know what version of RAkU to use?

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.

What is the difference between a statements and comments in raku?

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.

How does Raku's sort work?

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.

How do I interpolate variables in raku?

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.


1 Answers

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
like image 187
Elizabeth Mattijsen Avatar answered Sep 20 '22 05:09

Elizabeth Mattijsen