Fibonacci word: Difference between revisions
→{{header|jq}}: simplify
m (→{{header|jq}}: simplify) |
(→{{header|jq}}: simplify) |
||
Line 2,077:
</syntaxhighlight>
'''The task''':
<syntaxhighlight lang="jq">
def enumerate(s): foreach s as $x (-1; .+1; [., $x]);
# as a stream of arrays of the form [index, word]▼
def fibonacci_words(n):▼
def fibonacci_words:
"1",
(["0","1"]
| recurse([add, .[0]])
# Generate the first n terms of the Fibonacci word sequence
▲# as a stream of arrays of the form [index, word] starting with [0,1]
▲def fibonacci_words($n):
enumerate(limit($n; fibonacci_words));
def task(n):
|