CMU Artificial Intelligence Repository
 
   
   
   
   
  
Select Match
lang/lisp/code/match/miranda/
The SELECT-MATCH macro is useful for implementing interpreters,
     (defun eval-expr (x)
       (select-match x
         ('add x y) => (+ x y)
         ('sub x y) => (- x y)
         ('mul x y) => (* x y)
         ('div x y) => (/ x y)))
and also for programs in general,
     (defun my-append (a b)
       (select-match a
         'nil      =>  b
         (hd . tl) =>  (cons hd (my-append tl b))))
     (defun fact (n)
       (select-match n
          '0  =>  1
          n   =>  (* n (fact (1- n)))))
Origin:   
   ecs.soton.ac.uk:lisp/select.lisp
Copying:      Copying, distribution, and modification permitted.
CD-ROM:       Prime Time Freeware for AI, Issue 1-1
Author(s):    Stephen Adams 
              Computer Science
              Southampton University
              Southampton SO9 5NH, UK
Keywords:
   Authors!Adams, Lisp!Matchers, Matchers, Select Match
References:   ?
Last Web update on Mon Feb 13 10:30:11 1995 
AI.Repository@cs.cmu.edu