Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Set/Zkl/set.zkl
Normal file
21
Task/Set/Zkl/set.zkl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
var [const] unique = Utils.Helpers.listUnique;
|
||||
class Set {
|
||||
fcn init { var [const] set = (vm.arglist.copy() : unique(_)) }
|
||||
fcn holds(x) { set.holds(x) }
|
||||
fcn union(setB) { self(set.xplode(),setB.set.xplode()) }
|
||||
fcn intersection(setB){ sb:=setB.set;
|
||||
C:=self(); sc:=C.set;
|
||||
foreach x in (set){ if (sb.holds(x)) sc.append(x) }
|
||||
C
|
||||
}
|
||||
fcn diff(setB){ C:=self(); C.set.extend(set);
|
||||
setB.set.pump(Void,C.set.remove);
|
||||
C
|
||||
}
|
||||
fcn isSubset(setB){ sb:=setB.set;
|
||||
set.pump(Void,'wrap(x){
|
||||
if (not sb.holds(x)) return(Void.Stop,False); True
|
||||
})
|
||||
}
|
||||
fcn __opEQ(setB) { ((set.len() == setB.set.len()) and self.isSubset(setB)) }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue