Add code for determining item orientation

This commit is contained in:
2025-06-28 21:21:50 +01:00
parent 4f0dc64e72
commit 6af2a8cc36
7 changed files with 197 additions and 138 deletions
+15
View File
@@ -15,6 +15,21 @@ singleLDT x = LDT x [] []
ldtToDT :: LDTree b a -> DoubleTree a
ldtToDT (LDT x l r) = DT x (map (ldtToDT . snd) l) (map (ldtToDT . snd) r)
ldtStartPropagate :: (a -> c) -> (c -> b -> a -> c) -> LDTree b a -> LDTree b c
ldtStartPropagate g f (LDT x l r) = LDT z
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) l)
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) r)
where
z = g x
ldtPropagate' :: c -> b -> (c -> b -> a -> c) -> LDTree b a -> LDTree b c
ldtPropagate' x i f (LDT y l r) = LDT z
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) l)
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) r)
where
z = f x i y
-- propagate two functions down the links of an LDT tree
-- which function is chosen depends on whether it is a left or right branch
ldtPropagate ::