relpipe-data/examples-awk-boolean-logic.xml
branchv_0
changeset 258 2868d772c27e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples-awk-boolean-logic.xml	Tue May 28 21:18:20 2019 +0200
@@ -0,0 +1,61 @@
+<stránka
+	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
+	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
+	
+	<nadpis>Using boolean logic with AWK</nadpis>
+	<perex>boolean data type and logical AND, OR, XOR operators</perex>
+	<m:pořadí-příkladu>02500</m:pořadí-příkladu>
+
+	<text xmlns="http://www.w3.org/1999/xhtml">
+
+		<p>Expect that we have a relation with four combinations of logical values:</p>
+		
+		<pre><![CDATA[logic:
+╭─────────────┬─────────────╮
+│ a (boolean) │ b (boolean) │
+├─────────────┼─────────────┤
+│        true │        true │
+│        true │       false │
+│       false │        true │
+│       false │       false │
+╰─────────────┴─────────────╯
+Record count: 4]]></pre>
+
+		<p>
+			we can use logical operators and functions:
+		</p>
+
+		
+		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli \
+	generate logic 2 \
+		a boolean \
+		b boolean \
+		true  true \
+		true  false \
+		false true \
+		false false \
+	| relpipe-tr-awk \
+		--relation '.*' \
+			--output-attribute AND boolean \
+			--output-attribute OR  boolean \
+			--output-attribute XOR boolean \
+			--input-attributes-prepend \
+			--for-each '{ AND = a && b; OR = a || b; XOR = xor(a,b); record(); }' \
+	| relpipe-out-tabular]]></m:pre>
+	
+		<p>and append their results to the relation as additional attributes:</p>
+	
+		<pre><![CDATA[logic:
+ ╭─────────────┬─────────────┬───────────────┬──────────────┬───────────────╮
+ │ a (boolean) │ b (boolean) │ AND (boolean) │ OR (boolean) │ XOR (boolean) │
+ ├─────────────┼─────────────┼───────────────┼──────────────┼───────────────┤
+ │        true │        true │          true │         true │         false │
+ │        true │       false │         false │         true │          true │
+ │       false │        true │         false │         true │          true │
+ │       false │       false │         false │        false │         false │
+ ╰─────────────┴─────────────┴───────────────┴──────────────┴───────────────╯
+Record count: 4]]></pre>
+		
+	</text>
+	
+</stránka>