Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (polaczenia w)
- (case w
- ('s '((a . 5) (d . 4)))
- ('d '((a . 5) (s . 4) (e . 1)))
- ('a '((d . 5) (s . 5) (b . 3)))
- ('b '((a . 3) (e . 6) (c . 2)))
- ('e '((d . 1) (b . 6) (f . 2)))
- ('c '((b . 2)))
- ('f '((e . 2) (g . 3)))
- ('g '((f . 3)))
- )
- )
- (define (wsp w)
- (case w
- ('s '(1 . 3))
- ('a '(3 . 1))
- ('d '(4 . 5))
- ('b '(6 . 1))
- ('e '(5 . 5))
- ('f '(7 . 5))
- ('c '(8 . 2))
- ('g '(9 . 3))
- )
- )
- (define (mapuj f a)
- (if (null? a)
- '()
- (cons
- (f (car a))
- (mapuj f (cdr a))
- )
- )
- )
- (define (szukaj x l)
- (if (null? l) #f (if (equal? x (car l)) #t (szukaj x (cdr l))))
- )
- (define (odwroc a) (odwroc_ a '()))
- (define (odwroc_ a b) (if (null? a) b (odwroc_ (cdr a) (cons (car a) b))))
- (define (SzukajWGlab start cel) (odwroc (SzukajWGlabPom cel (list start))))
- (define (SzukajWGlabPom cel droga)
- (if (equal? (car droga) cel)
- droga
- (SzukajWGlabPrzez cel droga (mapuj car (polaczenia (car droga))))
- )
- )
- (define (SzukajWGlabPrzez cel droga sasiedzi)
- (if (null? sasiedzi)
- '()
- (if (szukaj (car sasiedzi) droga)
- (SzukajWGlabPrzez cel droga (cdr sasiedzi))
- (if (null? (SzukajWGlabPom cel (cons (car sasiedzi) droga)))
- (SzukajWGlabPrzez cel droga (cdr sasiedzi))
- (SzukajWGlabPom cel (cons (car sasiedzi) droga))
- )
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment