Make torch use battery power

This commit is contained in:
2024-10-02 23:53:38 +01:00
parent 49ffbfafc2
commit 844bb486e6
13 changed files with 72 additions and 76 deletions
+16
View File
@@ -38,6 +38,22 @@ ldtPropagateFold lf rf up x (LDT v l r) =
. alaf Endo foldMap (\(s,y) -> ldtPropagateFold lf rf up (lf x v s (_ldtValue y)) y) l
. up x v
-- Propgates a value (of type c) down the branches of the LDT.
-- The value is updated according a "left" or "right" function (lf or rf),
-- that acts on the parent value, the link, and the child value.
-- For each node-tree, the updated value is used to update a final value (of type d).
ldtPropagateFoldTree :: (c -> a -> b -> a -> c)
-> (c -> a -> b -> a -> c)
-> (c -> LabelDoubleTree b a -> d -> d)
-> c
-> LabelDoubleTree b a
-> d
-> d
ldtPropagateFoldTree lf rf up x t@(LDT v l r) =
alaf Endo foldMap (\(s,y) -> ldtPropagateFoldTree lf rf up (rf x v s (_ldtValue y)) y) r
. alaf Endo foldMap (\(s,y) -> ldtPropagateFoldTree lf rf up (lf x v s (_ldtValue y)) y) l
. up x t
ildtPropagate :: (Int -> c -> b -> c) -> (Int -> c -> b -> c)
-> c
-> LabelDoubleTree b a -> LabelDoubleTree c a