Last active
January 26, 2016 03:44
-
-
Save dardo82/1377bba81076358084da to your computer and use it in GitHub Desktop.
Operations with sets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
join -1 2 -2 2 <(echo ${${1//,/\\n}//({|})/}) <(echo ${${2//,/\\n}//({|})/})|gsed 's/^ /(/;s/ /,/;s/$/)/;s/\n/,/'|gsed -z 's/\n/,/g;s/^/{/;s/,$/}\n/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
S=$(eval echo\ "\{\,-$1-\}") | |
P=$(eval echo\ "{${S// /}}") | |
echo {${${P//(--| )/,}//-/}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SET1='{a,b,c}'; SET2='{1,2,3}'
./power-set.sh $SET1
./power-set.sh $SET2
./cart-prod.sh $SET1 $SET2