Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Test-integerness/Jq/test-integerness-1.jq
Normal file
10
Task/Test-integerness/Jq/test-integerness-1.jq
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
def is_integral:
|
||||
if type == "number" then . == floor
|
||||
elif type == "array" then
|
||||
length == 2 and .[1] == 0 and (.[0] | is_integral)
|
||||
else type == "object"
|
||||
and .type == "rational"
|
||||
and .q != 0
|
||||
and (.q | is_integral)
|
||||
and ((.p / .q) | is_integral)
|
||||
end ;
|
||||
4
Task/Test-integerness/Jq/test-integerness-2.jq
Normal file
4
Task/Test-integerness/Jq/test-integerness-2.jq
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(
|
||||
0, -1, [3,0], {"p": 4, "q": 2, "type": "rational"},
|
||||
1.1, -1.1, [3,1], {"p": 5, "q": 2, "type": "rational"}
|
||||
) | "\(.) => \(if is_integral then "integral" else "" end)"
|
||||
9
Task/Test-integerness/Jq/test-integerness-3.jq
Normal file
9
Task/Test-integerness/Jq/test-integerness-3.jq
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
$ jq -r -n -f is_integral.jq
|
||||
0 => integral
|
||||
-1 => integral
|
||||
[3,0] => integral
|
||||
{"p":4,"q":2,"type":"rational"} => integral
|
||||
1.1 =>
|
||||
-1.1 =>
|
||||
[3,1] =>
|
||||
{"p":5,"q":2,"type":"rational"} =>
|
||||
Loading…
Add table
Add a link
Reference in a new issue