Exactly three adjacent 3 in lists: Difference between revisions
Content added Content deleted
(→{{header|jq}}: use index/1) |
|||
Line 352: | Line 352: | ||
The test cases, and the output, are exactly as for entry at [[#Wren]]. |
The test cases, and the output, are exactly as for entry at [[#Wren]]. |
||
⚫ | |||
⚫ | |||
⚫ | |||
# Output: a stream of arrays of length $w |
|||
⚫ | |||
def moving_window($w): |
|||
select(length >= $w) |
|||
| recurse( .[1:]; length >= $w) | .[:$w];</lang> |
|||
'''The task''' |
'''The task''' |
||
<lang jq>def lists : [ |
<lang jq>def lists : [ |
||
Line 373: | Line 369: | ||
def threeConsecutiveThrees: |
def threeConsecutiveThrees: |
||
count(.[] == 3 // empty) == 3 |
count(.[] == 3 // empty) == 3 |
||
and |
and index([3,3,3]); |
||
"Exactly three adjacent 3's:", |
"Exactly three adjacent 3's:", |
||
Line 381: | Line 377: | ||
{{out}} |
{{out}} |
||
As for [[#Wren]]. |
As for [[#Wren]]. |
||
=={{header|Julia}}== |
=={{header|Julia}}== |