Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > pt.comp.programacao > #276 > unrolled thread

o resto é Python

Started byPatricia Ferreira <pferreira@example.com>
First post2024-03-08 18:36 -0300
Last post2024-03-08 22:13 +0000
Articles 3 — 2 participants

Back to article view | Back to pt.comp.programacao


Contents

  o resto é Python Patricia Ferreira <pferreira@example.com> - 2024-03-08 18:36 -0300
    Re: o resto é Python Patricia Ferreira <pferreira@example.com> - 2024-03-08 18:48 -0300
    Re: o resto é Python Daniel Cerqueira <dan.list@lispclub.com> - 2024-03-08 22:13 +0000

#276 — o resto é Python

FromPatricia Ferreira <pferreira@example.com>
Date2024-03-08 18:36 -0300
Subjecto resto é Python
Message-ID<87sf10flsh.fsf@example.com>
Preciso de um procedimento que testa (sem sequência) se dois valors u, s
são nulos.  Se forem, retorne NIL.  Se não for, obtenha uns valores.
Eis como fazer:

(defun last-time-seen (username)
  (let ((u (get-account username)))
    (and u (let ((s (account-seen u)))
             (and s (universal-to-human s))))))

Moleza.  Mas eis como um Lisper realmente faz:

(defun last-time-seen (username)
  (when-let* ((u (get-account username))
              (s (account-seen u))
    (universal-to-human s)))

When-let*.  Isso é linguagem de /programação/.  O resto é Python.

[toc] | [next] | [standalone]


#278

FromPatricia Ferreira <pferreira@example.com>
Date2024-03-08 18:48 -0300
Message-ID<871q8kfl88.fsf@example.com>
In reply to#276
Patricia Ferreira <pferreira@example.com> writes:

> Preciso de um procedimento que testa (sem sequência) se dois valors u, s
> são nulos.  Se forem, retorne NIL.  Se não for, obtenha uns valores.
> Eis como fazer:
>
> (defun last-time-seen (username)
>   (let ((u (get-account username)))
>     (and u (let ((s (account-seen u)))
>              (and s (universal-to-human s))))))
>
> Moleza.  Mas eis como um Lisper realmente faz:
>
> (defun last-time-seen (username)
>   (when-let* ((u (get-account username))
>               (s (account-seen u))
>     (universal-to-human s)))
>
> When-let*.  Isso é linguagem de /programação/.  O resto é Python.

Mas, pra ser justo, isso não é Common Lisp.  Isso é Alexandria.

  Alexandria: https://alexandria.common-lisp.dev/

  --8<---------------cut here---------------start------------->8---
  Alexandria is a project and a library.

  As a project Alexandria's goal is to reduce duplication of effort and
  improve portability of Common Lisp code according to its own
  idiosyncratic and rather conservative aesthetic. What this actually
  means is open to debate, but each project member has a veto on all
  project activities, so a degree of conservativism is inevitable.
  --8<---------------cut here---------------end--------------->8---

[toc] | [prev] | [next] | [standalone]


#279

FromDaniel Cerqueira <dan.list@lispclub.com>
Date2024-03-08 22:13 +0000
Message-ID<87edckz81j.fsf@lispclub.com>
In reply to#276
Patricia Ferreira <pferreira@example.com> writes:

> Preciso de um procedimento que testa (sem sequência) se dois valors u, s
> são nulos.  Se forem, retorne NIL.  Se não for, obtenha uns valores.
> Eis como fazer:
>
> (defun last-time-seen (username)
>   (let ((u (get-account username)))
>     (and u (let ((s (account-seen u)))
>              (and s (universal-to-human s))))))
>
> Moleza.  Mas eis como um Lisper realmente faz:
>
> (defun last-time-seen (username)
>   (when-let* ((u (get-account username))
>               (s (account-seen u))
>     (universal-to-human s)))
>
> When-let*.  Isso é linguagem de /programação/.  O resto é Python.

Uuuauuuuuuu! Desconhecia o when-let.
Acho que vai-me ser muito útil.
:-)

[toc] | [prev] | [standalone]


Back to top | Article view | pt.comp.programacao


csiph-web