Substitution for Partial Terms? (Ersetzung von Teiltermen) ---------------------------------------------------------------------- > module Replace ( replace > ) > where ---------------------------------------------------------------------- ---------------------------------------------------------------------- > import Prim > import Function ( Prim(..), Function(..) ) ---------------------------------------------------------------------- Substitution ---------------------------------------------------------------------- > replace :: (Function, Function) -> Function -> Function > replace b@(g, h) f > | g == f = h > | otherwise = replace' b f ---------------------------------------------------------------------- ---------------------------------------------------------------------- > replace' b (Derive n f) = Derive n (replace b f) > replace' b (f :.: g) = replace b f :.: replace b g > replace' b (Summ fs) = Summ [ replace b f | f<-fs ] > replace' b (Prod fs) = Prod [ replace b f | f<-fs ] > replace' b (f :^: g) = replace b f :^: replace b g > replace' b f = f ----------------------------------------------------------------------