X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FSearch.scl;fp=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FSearch.scl;h=0000000000000000000000000000000000000000;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hp=352e92c742f0d8840fff5116b70b67a0d26486c6;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/Search.scl b/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/Search.scl deleted file mode 100644 index 352e92c74..000000000 --- a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/Search.scl +++ /dev/null @@ -1,47 +0,0 @@ -import "Prelude" hiding (findFirst) - -infinity = 1e9 - -@inline -findFirst :: (a -> Maybe b) -> [a] -> Maybe b -findFirst f l = loop 0 - where - len = length l - loop i - | i >= len = Nothing - | otherwise = match f (l!i) with - s @ (Just _) -> s - Nothing -> loop (i+1) - -dfsFirst :: (a -> Boolean) -> (a -> [a]) -> [a] -> (Maybe a) -dfsFirst acceptable successors initial = tryAll initial - where - tryAll l = findFirst loop l - loop p - | acceptable p = Just p - | otherwise = tryAll (successors p) - -data Weighted a = Weighted a Double - -//type SearchAlgorithm e a = -// (a -> Boolean) -> (a -> [Weighted a]) -> [Weighted a] -> Weighted (Maybe a) - -//dfs :: SearchAlgorithm e a -dfs :: (a -> Boolean) -> (a -> [Weighted a]) -> [Weighted a] -> Weighted (Maybe a) -dfs acceptable successors initial = foldl loop (Weighted Nothing infinity) initial - where - loop best@(Weighted _ bestW) (Weighted p w) - | w >= bestW = best - | acceptable p = Weighted (Just p) w - | otherwise = foldl loop best - $ map (\(Weighted p' w') -> Weighted p' (w+w')) - $ successors p - -/* -bfs :: SearchAlgorithm e a - -aStar :: (a -> Double) -> SearchAlgorithm e a -*/ -main = "Hello" --- -Hello \ No newline at end of file