Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.02 KB | None | 0 0
  1. (define Alle-Operatoren
  2. '(Käsebrot-kaufen Schinkenbrot-kaufen Schokolade-50g Schokolade-100g Dosenbier))
  3.  
  4. (define (Suche Zustand Operatoren Pfad)
  5. ; Backtracking-Verfahren , Version 1
  6.   (cond ((Zielp? Zustand) Pfad)     ;(1)
  7.         ((Endep? Zustand) '())      ;(2)
  8.         ((null? Operatoren) '())    ;(3)
  9.         ((not (null? (Suche (Wende-an (car Operatoren) Zustand) ;(4)
  10.                             Alle-Operatoren
  11.                             (cons (car Operatoren) Pfad))))
  12.          (Suche (Wende-an (car Operatoren) Zustand) ;(4)
  13.                 Alle-Operatoren
  14.                 (cons (car Operatoren) Pfad)))
  15.         (else (Suche Zustand (cdr Operatoren) Pfad)))) ;(5)
  16.  
  17. (define (Wende-an Op z)
  18.   (cond ((equal? Op 'Käsebrot-kaufen) (- z 400))
  19.         ((equal? Op 'Schinkenbrot-kaufen) (- z 460))
  20.         ((equal? Op 'Schokolade-50g) (- z 155))
  21.         ((equal? Op 'Schokolade-100g) (- z 290))
  22.         ((equal? Op 'Dosenbier) (- z 350))
  23.         ))
  24.  
  25. (define (Zielp? z)
  26.   (= z 0))
  27.  
  28. (define (Endep? z)
  29.   (< z 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement