Contents    Page-10    Prev    Next    Page+10    Index   

Design Pattern: Depth-first Search

(defn search [state] ; returns path to goal
         (if (goal? state)
         '() ; no ops needed to get to goal
         (if (failure? state)
         nil
         (some
         (fn [op]
         (let
         [path (search
         (applyop op state ))]
         (and path (cons op path)) ))
         (operators state)) )))

Complications: