Created
November 14, 2012 19:47
-
-
Save twfarland/4074309 to your computer and use it in GitHub Desktop.
shortest path racket version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require "../connive/connive.rkt") | |
;; :: (state -> [state]), (state -> Bool), state -> [state] | |
(:= (blocking-path get-successors goal? start) | |
;; :: (set state), [state] -> #f | [state] | |
(:== solution (blocked path) | |
(_ (cons (list state info) prevs)) | |
(?? (goal? (list state info)) (reverse path) | |
(lyt (now-blocked (set-add blocked state)) | |
(first-solution now-blocked path (<- s s (get-successors (list state info)) | |
(not (set-member? now-blocked (first s)))))))) | |
;; :: (set state), [state], [state] -> #f | [state] | |
(:== first-solution (blocked path states) | |
(_ _ empty) #f | |
(_ _ (cons state states)) (or (solution blocked (cons state path)) | |
(first-solution blocked path states))) | |
(solution (set) (list start))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment