Add getSquareByZipper function
This commit is contained in:
parent
76afaae38e
commit
534f0f9609
@ -6,6 +6,7 @@ module Algorithms.RangeSearch.Core
|
||||
goQuad,
|
||||
findNeighbor,
|
||||
lookupByPath',
|
||||
getSquareByZipper,
|
||||
rootNode,
|
||||
testArr,
|
||||
Orient(North,East,West,South),
|
||||
@ -101,6 +102,18 @@ quadTreeSquares sq (TNode nw ne sw se) =
|
||||
quadTreeSquares (swSq sq) sw ++ quadTreeSquares (seSq sq) se
|
||||
|
||||
|
||||
-- |Get the current square of the zipper, relative to the to the given top
|
||||
-- square.
|
||||
getSquareByZipper :: Square -> Zipper a -> Square
|
||||
getSquareByZipper sq z = go sq (reverse . snd $ z)
|
||||
where
|
||||
go sq' [] = sq'
|
||||
go sq' (NWCrumb {}:zs) = go (nwSq sq') zs
|
||||
go sq' (NECrumb {}:zs) = go (neSq sq') zs
|
||||
go sq' (SWCrumb {}:zs) = go (swSq sq') zs
|
||||
go sq' (SECrumb {}:zs) = go (seSq sq') zs
|
||||
|
||||
|
||||
-- |Left fold over the tree leafs.
|
||||
qtFoldl :: (a -> b -> a) -> a -> QuadTree b -> a
|
||||
qtFoldl _ sv (TNil) = sv
|
||||
|
Loading…
Reference in New Issue
Block a user