Deutsch English Français Italiano |
<v707ep$3enb$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "B. Pym" <Nobody447095@here-nor-there.org> Newsgroups: comp.lang.lisp Subject: re: Advice for a new lisper Date: Sun, 14 Jul 2024 09:57:50 -0000 (UTC) Organization: A noiseless patient Spider Lines: 25 Message-ID: <v707ep$3enb$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Sun, 14 Jul 2024 11:57:50 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2af9a93e51c2354c9c01f27f8d2b9bf3"; logging-data="113387"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3mFvJu8DSMvVfYnGTvmf2" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:wHQd+avSF/SAjmYk9v/n9TSeQNE= Bytes: 1519 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)))