Jump to content

Maximum difference between adjacent elements of list: Difference between revisions

→‎{{header|J}}: maybe simpler
(→‎{{header|J}}: maybe simpler)
Line 582:
 
=={{header|J}}==
<syntaxhighlight lang="j">maxdiff =: ([: (([:>,.|@-/]"1) 2(,.[/\ (#~] (=[:>./])[@:|@) -/"1]\)@(2:,/\ ])</syntaxhighlight>
{{out}}
<pre> maxdiff 1 8 2 _3 0 1 1 _2.3 0 5.5 8 6 2 9 11 10 3
7 1 8 7
7 2 9 7
7 10 3</pre> 7
(}:,&":' ==> ',&":{:)"1 maxdiff 1 8 2 _3 0 1 1 _2.3 0 5.5 8 6 2 9 11 10 3
1 8 ==> 7
2 9 ==> 7
10 3 ==> 7</pre>
 
=={{header|jq}}==
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.