Add new files
This commit is contained in:
@@ -12,21 +12,6 @@ import Data.Maybe
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
|
||||
-- | A version of 'minimum' where the comparison is done on some extracted value.
|
||||
-- Returns Nothing if the list is empty. Only calls the function once per element.
|
||||
--
|
||||
-- > safeMinimumOn id [] == Nothing
|
||||
-- > safeMinimumOn length ["test","extra","a"] == Just "a"
|
||||
safeMinimumOn' :: (Ord b) => (a -> b) -> [a] -> Maybe a
|
||||
safeMinimumOn' _ [] = Nothing
|
||||
safeMinimumOn' f (x:xs) = g x (f x) xs
|
||||
where
|
||||
g v _ [] = Just v
|
||||
g v mv (y:ys) | my < mv = g y my ys
|
||||
| otherwise = g v mv ys
|
||||
where my = f y
|
||||
|
||||
|
||||
hasLOS :: Point2 -> Point2 -> World -> Bool
|
||||
{-# INLINE hasLOS #-}
|
||||
hasLOS p1 p2 w = not $ pointHitsWalls p1 p2 $ wallsAlongLine p1 p2 w
|
||||
|
||||
Reference in New Issue
Block a user