Re: diff1(x) in Python: True if all adjacent items (Posting On Python-List Prohibited)

Liste des GroupesRevenir à cl python 
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.lisp
Date : 16. Jun 2024, 03: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]()

Date Sujet#  Auteur
15 Jun 24 * diff1(x) in Python: True if all adjacent items differ by 1, False otherwise.8HenHanna
15 Jun 24 `* Re: diff1(x) in Python: True if all adjacent items differ by 1, False otherwise.7Paul Rubin
16 Jun 24  `* Re: diff1(x) in Python: True if all adjacent items differ by 1, False otherwise.6HenHanna
16 Jun 24   +- Re: diff1(x) in Python: True if all adjacent items differ by 1, False otherwise.1Kaz Kylheku
16 Jun 24   +* Re: diff1(x) in Python: True if all adjacent items differ by 1, False otherwise.3HenHanna
16 Jun 24   i+- Re: diff1(x) in Python: True if all adjacent items (Posting On Python-List Prohibited)1Lawrence D'Oliveiro
16 Jun 24   i`- Re: diff1(x) in Python: True if all adjacent items differ by 1, False otherwise.1HenHanna
17 Jun 24   `- Re: diff1(x) in Python: True if all adjacent items differ by 1, False otherwise.1Michael F. Stemper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal