relpipe-data/examples-awk-boolean-logic.xml
author František Kučera <franta-hg@frantovo.cz>
Mon, 21 Feb 2022 00:43:11 +0100
branchv_0
changeset 329 5bc2bb8b7946
parent 258 2868d772c27e
permissions -rw-r--r--
Release v0.18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
258
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
<stránka
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
	
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
	<nadpis>Using boolean logic with AWK</nadpis>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
	<perex>boolean data type and logical AND, OR, XOR operators</perex>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
	<m:pořadí-příkladu>02500</m:pořadí-příkladu>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
	<text xmlns="http://www.w3.org/1999/xhtml">
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
		<p>Expect that we have a relation with four combinations of logical values:</p>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
		
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
		<pre><![CDATA[logic:
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
╭─────────────┬─────────────╮
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
│ a (boolean) │ b (boolean) │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
├─────────────┼─────────────┤
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
│        true │        true │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
│        true │       false │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
│       false │        true │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
│       false │       false │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
╰─────────────┴─────────────╯
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
Record count: 4]]></pre>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
		<p>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
			we can use logical operators and functions:
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
		</p>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
		
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	generate logic 2 \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
		a boolean \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
		b boolean \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
		true  true \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
		true  false \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
		false true \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
		false false \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	| relpipe-tr-awk \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
		--relation '.*' \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
			--output-attribute AND boolean \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
			--output-attribute OR  boolean \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
			--output-attribute XOR boolean \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
			--input-attributes-prepend \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
			--for-each '{ AND = a && b; OR = a || b; XOR = xor(a,b); record(); }' \
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
	| relpipe-out-tabular]]></m:pre>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
	
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		<p>and append their results to the relation as additional attributes:</p>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
		<pre><![CDATA[logic:
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
 ╭─────────────┬─────────────┬───────────────┬──────────────┬───────────────╮
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
 │ a (boolean) │ b (boolean) │ AND (boolean) │ OR (boolean) │ XOR (boolean) │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
 ├─────────────┼─────────────┼───────────────┼──────────────┼───────────────┤
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
 │        true │        true │          true │         true │         false │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
 │        true │       false │         false │         true │          true │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
 │       false │        true │         false │         true │          true │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
 │       false │       false │         false │        false │         false │
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
 ╰─────────────┴─────────────┴───────────────┴──────────────┴───────────────╯
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
Record count: 4]]></pre>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
		
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	</text>
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	
2868d772c27e Release v0.12 – AWK
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
</stránka>