From 1462786d4ed7ec98ab6721a8238c5ed41f4bc5b7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 21 Jan 2013 03:01:35 +0100 Subject: info: using MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- .gitignore | 24 ++++++++++++++++++++++++ sets.py | 3 ++- sets.texinfo | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ee6d023..fb96e4d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,27 @@ __pycache__/ *~ *.bak *.swp +*.pdf +*.ps +*.dvi +*.info + +/dist/*/*/* +!/dist/*/*/PKGBUILD +*.gz +*.xz + +/sets.aux +/sets.cp +/sets.cps +/sets.fn +/sets.ky +/sets.log +/sets.pg +/sets.toc +/sets.tp +/sets.vr +/sets.op +/sets.ops +/sets.pgs +/sets.vrs \ No newline at end of file diff --git a/sets.py b/sets.py index d9330a4..89dc61c 100755 --- a/sets.py +++ b/sets.py @@ -83,7 +83,7 @@ if sys.argv[1].startswith('-'): print( ' ^ ⊕ ∆ ⊗ ⊻ Symmetrical difference (parity/xor)') print( ' & * ∧ ⋀ ∩ ⋂ Intersection (and)') print( ' | + ∨ ⋁ ∪ ⋃ Union (or)') - print(' - \\ ↛ Difference (material nonimplication/abjunction)') + print(' - − \\ ↛ Difference (material nonimplication/abjunction)') print( ' 0 ∅ Empty set (false)') print( ' U Ω Ω 𝓤 Universe (true)') print() @@ -210,6 +210,7 @@ formula = formula.replace('∪', '|').replace('⊗', '^').replace('⊻', '^') formula = formula.replace('⋀', '&').replace('⋁', '|').replace('⋂', '&') formula = formula.replace('⋃', '|').replace('Ω', 'U').replace('Ω', 'U') formula = formula.replace('⊕', '^').replace('𝓤', 'U').replace('↛', '-') +formula = formula.replace('−', '-') for i in range(0, 10): diff --git a/sets.texinfo b/sets.texinfo index 18071ff..68fb3d9 100644 --- a/sets.texinfo +++ b/sets.texinfo @@ -70,6 +70,11 @@ Texts. A copy of the license is included in the section entitled @cindex overview @cindex description +@command{sets} is a practical way to do set operations in the shell. +@command{sets} lets you use a normal algebraic expression for way you +want returned and supply the sets via stdin. + + @node Invoking @chapter Invoking @@ -84,11 +89,64 @@ Texts. A copy of the license is included in the section entitled @cindex @option{-w} @cindex @option{--warranty} +@command{sets} can be started with @option{-c}, @option{--copying} or +@option{--copyright} for displaying copyright information, @option{-w} or +@option{--warranty} for displaying a warranty disclaimer. If any other +options is used, help information is displayed. + +To actually use @command{sets} use one argument expressing the formula +you want calculated (and no other arguments.) The expression is written +in normal algebra, meaning the you use operand–operator–operand style +expression. For example, to get the elements in set 1, that does not +exist in set 2 nor set 3, the expression is @code{1 - 2 - 3}. And yes +the sets are numbers from 1 and up in decimal. + +The sets are fetched from stdin. + @node Using @chapter Using @cindex usage +To use @command{sets} use one argument expressing the formula you want +calculated (and no other arguments.) The expression is written in normal +algebra, meaning the you use operand–operator–operand style expression. +For example, to get the elements in set 1, that does not exist in set 2 +nor set 3, the expression is @code{1 - 2 - 3}. And yes the sets are numbers +from 1 and up in decimal. Set 0 represents the empty set, and the universe +is represented by @code{U}, and is an union of all sets. + +The supported operators are complement (not), symmetrical difference +(parity/xor), intersection (and), union (or), difference (material +nonimplication/abjunction). If your display is limited run @command{sets --help} +to get this list (it should be complete if you use @command{info}); +the recognised symbols for the operators (and sets) are: + +@table @asis +@item Complement +~ C ∁ ! ¬ +@item Symmetrical difference +^ ⊕ ∆ ⊗ ⊻ +@item Intersection +& * ∧ ⋀ ∩ ⋂ +@item Union +| + ∨ ⋁ ∪ ⋃ +@item Difference +- − \ ↛ +@item Empty set +0 ∅ +@item Universe +U Ω Ω 𝓤 +@end table + +Round brackets are recognised for evaluation order grouping. + +The sets are fetched from stdin, a line in stdin in an element, sets +are seperated by blank lines, and you can have any number of blank +lines, meaning that you cannot have empty sets. But if you want +empty set you should just use an element that you know is a false +element, perhaps a dot. + @node Behind the scenes @chapter Behind the scenes -- cgit v1.2.3-70-g09d2