useRule :: Rule -> Interval -> ([Interval], [Interval], [Rule])
useRule (Rule (Iv rl rh) d) (Iv xl xh) = (newResults, newVals, newRules)
where newResults =
- filter legalInterval [ Iv (min xl rl) (min xh (rl - 1)) -- input below rule
+ filter legalInterval [ Iv xl (rl - 1) -- input below rule
, Iv ((max xl rl) + d) ((min xh rh) + d)] -- input within rule
- newVals = filter legalInterval [Iv (max xl (rh + 1)) (max xh rh)] -- input above rule
- newRules = filter legalRule [Rule (Iv (max (xh + 1) rl) (max xh rh)) d] -- rule above input
+ newVals = filter legalInterval [Iv (rh + 1) xh] -- input above rule
+ newRules = filter legalRule [Rule (Iv (xh + 1) rh) d] -- rule above input
+
useRules :: [Rule] -> [Interval] -> [Interval]
useRules [] vals = vals