Maximum difference between adjacent elements of list: Difference between revisions

Content added Content deleted
(Add J)
(Realize in F#)
Line 171: Line 171:
7 10 3</pre>
7 10 3</pre>


=={{header|F_Sharp|F#}}==
<lang fsharp>
// Max diff 'twix adj elems. Nigel Galloway: July 18th., 2021
let n,g=[1;8;2;-3;0;1;1;-2;3;0;5;5;8;6;2;9;11;10;3]|>List.pairwise|>List.groupBy(fun(n,g)->abs(n-g))|>List.maxBy fst in printfn "Pairs %A have the max diff of %d" g n
</lang>
{{out}}
<pre>
Pairs [(1, 8); (2, 9); (10, 3)] have the max diff of 7
</pre>
=={{header|Factor}}==
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
{{works with|Factor|0.99 2021-06-02}}