Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Integer-comparison/Jq/integer-comparison-1.jq
Normal file
16
Task/Integer-comparison/Jq/integer-comparison-1.jq
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# compare/0 compares the first two items if they are numbers,
|
||||
# otherwise an "uncomparable" message is emitted.
|
||||
|
||||
def compare:
|
||||
def english:
|
||||
if .[0] < .[1] then "less than"
|
||||
elif .[0] == .[1] then "equal to"
|
||||
else "greater than"
|
||||
end;
|
||||
if (.[0]|type) == "number" and (.[1]|type) == "number" then
|
||||
"\(.[0]) is \(english) \(.[1])"
|
||||
else
|
||||
"\(.[0]) is uncomparable to \(.[1])"
|
||||
end ;
|
||||
|
||||
compare
|
||||
7
Task/Integer-comparison/Jq/integer-comparison-2.jq
Normal file
7
Task/Integer-comparison/Jq/integer-comparison-2.jq
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
$ jq -s -r -f Integer_comparison.jq
|
||||
1 2
|
||||
1 is less than 2
|
||||
|
||||
$ jq -s -r -f Integer_comparison.jq
|
||||
1 "a"
|
||||
1 is uncomparable to a
|
||||
Loading…
Add table
Add a link
Reference in a new issue