RosettaCodeData/Task/First-class-environments/Jq/first-class-environments-1.jq
2023-07-01 13:44:08 -04:00

5 lines
217 B
Text

def code:
# Given an integer as input, compute the corresponding hailstone value:
def hail: if . % 2 == 0 then ./2|floor else 3*. + 1 end;
if .value > 1 then (.value |= hail) | .count += 1 else . end;