2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/
This is neat, methinks.
A couple of questions/points:
- Is the
|| any (== s') rs
part ofcanReachExcluding
necessary? - In the same definition, the part
rs = reach1From s au \\ ex
takes time linear in the size ofex
. Using a set (or hash) instead of a list forex
would probably improve your running time significantly in practice. But of course, that'd likely be at the expense of the clarity of your beautiful program. - You are of course right that your program checks "states excluded in other branches". What you are "really" implementing is depth-first search (DFS) on the graph defined by the automaton, and so you might want to look for a more efficient (functional) implementation of DFS. In that case, you could either look at the Haskell Library implementation, or maybe just this quick-and-dirty approach.
Søren Debois
- 376
- 1
- 7
default