Sha256: b9adaeeb1a8414934d180cf28c9a7afa774f9332fcbfaefbf05d38b83721349b

Contents?: true

Size: 447 Bytes

Versions: 10

Compression:

Stored size: 447 Bytes

Contents

# Lines which do not have two integers are skipped:

def arithmetic:
  split(" ") | select(length > 0) | map(tonumber)
  | if length > 1 then
    .[0] as $a | .[1] as $b
    | "For a = \($a) and b = \($b):\n" +
      "a + b = \($a + $b)\n" +
      "a - b = \($a - $b)\n" +
      "a * b = \($a * $b)\n" +
      "a/b|floor = \($a / $b | floor)\n" +
      "a % b = \($a % $b)\n" +
      "a | exp = \($a | exp)\n"
    else empty
    end ;

arithmetic

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/jq.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/jq.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/jq.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/jq.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/jq.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/jq.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/jq.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/jq.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/jq.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/jq.txt