loopとfix

話とかは気が向いたら書く…

decList x = x:if x == 0 then [] else decList (x - 1)
fix $ \f x->x:if x == 0 then [] else f (x - 1)
\f x->x:if x == 0 then [] else f (x - 1)

fix :: (a->a)->a
loop :: a (b, d) (c, d)->a b c

fix f = f $ fix f
loop f b = let (c, d) = f (b, d) in c

\f x->x:if x == 0 then [] else f (x - 1)

loop f b = let (c,d) = f (b,d) in c
fst $ f (b, snd $ f (b, snd $ f (b, ...)))

(\f x->if x == 0 then [0] else x:f (x-1))
\(a, f)->(f a, \b->if b == 0 then [0] else b:f (b-1))
\(a, f1)->(f1 a, \b->if b == 0 then [0] else b:f1 (b-1))

(\f x->if x == 0 then [0] else x:f (x-1))

fixToLoop :: ((a->b)->a->b)->(a, a->b)->(b, a->b)
fixToLoop f (a, g) = (g a, f g)

\f x y->if y == 1 then x else f (x*y) (y-1)
(a, a->a->a)->(a->a, a->a->a)
\(a, f)->(f a, \x y->if y == 1 then x else f (x*y) (y-1))
\f x y->x:f (x*y) (y+1)
\(a, f)->(f a, \x y->x:f (x*y) (y+1))