Ordered words: Difference between revisions
Content added Content deleted
m (→{{header|jq}}: rm extraneous #) |
(→{{header|jq}}: simplify and speed-up) |
||
Line 1,757: | Line 1,757: | ||
=={{header|jq}}== |
=={{header|jq}}== |
||
{{works with|jq|1.4}} |
{{works with|jq|1.4}} |
||
⚫ | |||
<lang jq># If your jq already defines until/2, then the following definition can be omitted: |
|||
⚫ | |||
def until(cond; next): |
|||
else .[0] <= .[1] and (.[1:] | is_sorted) |
|||
def _until: if cond then . else (next|_until) end; |
|||
end; |
|||
# input should be an array |
|||
⚫ | |||
⚫ | |||
else . as $in |
|||
| (length - 1) as $lm1 |
|||
| $lm1 == (0 | until( . == $lm1 or $in[.] > $in[.+1] ; .+1)) |
|||
end ; |
|||
def longest_ordered_words: |
def longest_ordered_words: |