[plt-scheme] HTDP 28.1.1 help ????
Hi together,
well scheme really is a fine language, but where I can't go further I can't
go further
Looking into exercise of HTDP 28.1.1 I have the following:
(define Graph '(
(A (B E))
(B (E F))
(C (B D))
(D ())
(E (C F))
(F (D G))
(G ())))
;; find-route : node node graph -> (listof node) or false
;; to create a path from origination to destination in G
;; if there is no path, the function produces false
(define (find-route origination destination G)
(cond
[(symbol=? origination destination)
(list destination)]
[else (local
((define possible-route
(find-route/list (neighbors origination G)
destination G)))
(cond
[(boolean? possible-route) false]
[else (cons origination possible-route)]))]))
;; find-route/list : (listof node) node graph -> (listof node) or false
;; to create a path from some node on lo-originations to destination
;; if there is no path, the function produces false
(define (find-route/list lo-Os D G)
(cond
[(empty? lo-Os) false]
[else (local ((define possible-route
(find-route (first lo-Os) D G)))
(cond
[(boolean? possible-route)
(find-route/list
(rest lo-Os) D G)]
[else possible-route]))]))
;; find-route : node node nodegraph -> (listof node) or false
;; to create a path from origination to destination in G
;; returns false if there is no path otherwise
;; returns a list of nodes from origination to destination
;;(define (find-route origination destination G)
;...
;;)
;; test-call
(find-route 'A 'F Graph)
would be great if you could give me a feedback for a sollution.
take care
--
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner