Sujet : Re: diff1(x) in Python: True if all adjacent items (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.python comp.lang.lispDate : 16. Jun 2024, 02:10:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4le1s$3n6db$4@dont-email.me>
References : 1 2 3 4
User-Agent : Pan/0.158 (Avdiivka; )
On Sat, 15 Jun 2024 17:52:18 -0700, HenHanna wrote:
Lispers can learn from Pythonicity and vice versa.
diff2 = \
lambda x : \
(
lambda : True,
lambda : all(abs(a - b) == 1) for a, b in zip(x, x[1:]),
)[len(x) > 1]()