Maximum difference between adjacent elements of list: Difference between revisions
Maximum difference between adjacent elements of list (view source)
Revision as of 08:22, 18 November 2021
, 2 years agoAdded 11l
m (move ๐ด๐ถ๐ฃsection โโFree Pascal: introduced in preceding revision 549A2 to its ๐ฐ๐ธ๐ฏ section, mark as translation of Pascal) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 15:
10,3 ==> 7
<br><br>
=={{header|11l}}==
{{trans|Python}}
<lang 11l>F maxDeltas(ns)
V pairs = zip(ns, ns[1..]).map((a, b) -> (abs(a - b), (a, b)))
V delta = max(pairs, key' ab -> ab[0])[0]
R pairs.filter(ab -> @delta == ab[0])
V maxPairs = maxDeltas([Float(1), 8, 2, -3, 0, 1, 1, -2.3, 0, 5.5, 8, 6, 2, 9, 11, 10, 3])
L(ab) maxPairs
print(ab)</lang>
{{out}}
<pre>
(7, (1, 8))
(7, (2, 9))
(7, (10, 3))
</pre>
=={{header|ALGOL 68}}==
|