foldl, foldr f o l d l (+) 0 [ 1 , 2, 3, 4] 0 + [1, 2, 3, 4] 10 foldl, foldr foldr (:) [5,6] [1,2,3,4] [1, 2, 3, 4] [5,6] [4,5,6] [3,4,5,6] 1 [2,3,4,5,6] [1,2,3,4,5,6] Lambda abstrakce, částečná aplikace f x y = x + y f = (\x y -> x + y) a b = . . . (e) = (\a b -> ...) (a e ) = (\b -> a b) = () a ( b) = (\a -> a b) = f l i p () b f l i p :: (a -> b -> c) -> b -> a -> c f l i p f x y = f y x Pointfree (.) :: (b -> c) -> (a -> b) -> a -> c (f . g) x = f (g x) (.) f g x = f (g x) h x = f (g x) h x = (f . g) x h = f . ec 77-redukce x Pointfree - příklady f u v w x = u v ( w x ) X = f (g x) x = (f ˇ g) x = f ˇ g f u v w x = u v (w x) f u v w x = (u v . w) x f u v w x = (u v .) w x f u v = (u v .) f u v = (.) (u v) f u v = ( ( . ) . u) v f u v = ( ( . ) .) u v f = ( ( . ) .ú f = ( ( . ) ( .)) (\a -> b a) = (b ) po r?-redukci w a x r?-redukuj eme u a v (f e) = ((e) f) f = ( . ) ( . ) Pointfree - příklady h x y = q y . q x h x y = q y . q h x y = (.) (q y) (q h x y = flip (.) (q x) (q h x y = (flip (.) (q x) . q) h x = flip (.) (q x) . q h x = ( . q ) ( flip (.) (q x)) h x = (. q) ((flip (.) . q) x) h x = (. q) ((flip (.) . q) x) h x h x = f (g x) h x = (f . g) x h = f . g x x) f b a = flip f a b y) y po r?-redukci y f.(g.h) = f.g.h((. q) . (flip (.) . q)) x ( . q ) . flip (.) . q po r?-redukci x Pointfree - příklady h x = f (g x) h x = (f ˇ g) x h = f ˇ g f x y = q y (q x) f x y = q y (q x) f x y = flip q (q x) y f x = flip q (q x) f b a = flip f a b po r?-redukci y f x = flip q (q x) f x = (flip q . q) x f = flip q . q po r?-redukci x