Deutsch English Français Italiano |
<v90as0$380ne$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: shootout: implementing an interpreter Date: Wed, 7 Aug 2024 17:28:34 -0000 (UTC) Organization: A noiseless patient Spider Lines: 24 Message-ID: <v90as0$380ne$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Wed, 07 Aug 2024 19:28:35 +0200 (CEST) Injection-Info: dont-email.me; posting-host="7094501a9f209988b45d39573ac7d250"; logging-data="3408622"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oDyTrPjKwX8Zi7j1Lyopw" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:KEJY0frZhot5OTIV89LYFxQKkZQ= Bytes: 1395 Kent M. Pitman wrote: > (defun shrug (list) > (loop for (x . sublist-and-more) on list > for more = (member x sublist-and-more) > when more > collect `(g ,x ,(ldiff sublist-and-more more)))) > => SHRUG > > (shrug '(a b c a d b d)) > => ((G A (B C)) (G B (C A D)) (G D (B))) newLISP (define (shrug xs (x (pop xs))) (and xs (if (match (list '* x '*) xs) (cons (list 'g x ($it 0)) (shrug xs)) (shrug xs)))) (shrug '(a b c a d b d)) ((g a (b c)) (g b (c a d)) (g d (b)))