Re: shootout: implementing an interpreter

Liste des GroupesRevenir à cl lisp 
Sujet : Re: shootout: implementing an interpreter
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp
Date : 07. Aug 2024, 19:28:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v90as0$380ne$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
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)))

Date Sujet#  Auteur
7 Aug 24 * Re: shootout: implementing an interpreter2B. Pym
8 Aug 24 `- Re: shootout: implementing an interpreter1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal