re: Advice for a new lisper

Liste des GroupesRevenir à cl lisp 
Sujet : re: Advice for a new lisper
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp
Date : 14. Jul 2024, 11:57:50
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v707ep$3enb$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Kenny Tilton wrote:

(defun straightp (hand)
    (if (null (cdr hand))
        t
      (and (= (caar hand) (- (caadr hand) 1)) (straightp (cdr hand)))))
 
Not bad, except of course for the caar/caadr thing. Lisniks have an
irrational bias against recursion where iteration will do, so if they
turn on you just come back with:
 
       (loop for (c1 c2) on hand
             unless c2 return t
             unless <in order> return nil)

Gauche Scheme

;; Not a fully functional procedure; just for testing.
(define (in-order a b) (= 1 (- b a)))

(define (straight? hand)
  (every
    in-order
    hand
    (cdr hand)))

Date Sujet#  Auteur
14 Jul 24 o Re: Advice for a new lisper1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal