bashkit 0.20.1

Awesomely fast virtual sandbox with bash and file system
Documentation
# Conversion
def totype(p; e): if p then . else fromjson | if p then . else e end end;
def tonumber : totype(isnumber ; error("cannot parse as number" ));
def toboolean: totype(isboolean; error("cannot parse as boolean"));

# Arrays
def transpose: [range([.[] | length] | max) as $i | [.[][$i]]];

# Indexing
def in(xs)    : . as $x | xs | has     ($x);
def inside(xs): . as $x | xs | contains($x);
def  index($i): indices($i)[ 0];
def rindex($i): indices($i)[-1];

# Formatting
def @json: tojson;


# BASHKIT PATCH: jq refuses to divide by zero, so jaq-std's `0 / 0` and
# `1 / 0` definitions (and the filters built on them) are redefined.
# `gamma` is jq's log-gamma (C gamma()).
def infinite: 1e1000 * 1;
def nan: infinite - infinite;
def isnan:      . < nan and nan < .;
def isinfinite: . == infinite or  . == -infinite;
def isfinite:   isnumber and (isinfinite | not);
def isnormal:   isnumber and ((. == 0 or isnan or isinfinite) | not);
def logb:
    if . == 0.0 then -infinite
  elif isinfinite then infinite
  elif isnan then .
  else ilogb | . + 0.0 end;
def significand:
    if isinfinite or isnan then .
  elif . == 0.0 then 0.0
  else scalbln(.; ilogb | -1 * .) end;
def finites: select(isfinite);
def normals: select(isnormal);
def gamma: lgamma;