集合

求B的补集:
$A = 1, 2, 3, 4
$B = 2,4
$A | where {$B -notcontains $_}
 
求A,B的交集:
$A = 1, 2, 3, 4
$B = 2,4
$A | where {$B -contains $_}
 
求A,B的全集:
$A = 1, 2, 3, 4
$B = 2, 4, 9
$AjiaoB = $A | where {$B -contains $_}  #A与B的交集
$AA = $a | where {$AjiaoB -notcontains $_}  #$AjiaoB相对于$A的补集
$BB = $b | where {$AjiaoB -notcontains $_}  #$AjiaoB相对于$B的补集
($AjiaoB + $AA + $BB) | Sort-Object -Descending 

 

posted @ 2015-05-10 20:35  dongdonggeorge  阅读(196)  评论(0编辑  收藏  举报