Cyclops numbers: Difference between revisions

→‎{{header|jq}}: def cyclops:
(→‎{{header|jq}}: def cyclops:)
Line 777:
;
 
# Generate a stream of cyclops numbers beginning with 0 and, in increasing numeric order., from 0
def cyclops:
# generate a stream of cyclops numbers as strings with $n digits on each side of the central 0
def cw: . as $n
| if $n. == 0 then "0"
else (.-1)|w elifas $n == 1left
| $left then+ (range(1;10)|tostring) + "0"
end;
| . + (range(1; 10)|tostring) # right
def c: w as $left | $left + "0" + w;
else (range(1;10)|tostring) # leftmost
| . + (range(pow(10;$n-2); pow(10; $n-1))|tostring|select(test("0")|not)) + "0"
| . + (range(pow(10;$n-1); pow(10; $n))|tostring|select(test("0")|not))
end;
range(0; infinite) | c | tonumber;
 
2,462

edits