map :: (a -> b) -> [a] -> [b] map f [] = [] map f (x:xs) = f x : map f xs filter :: (a -> Bool) -> [a] -> [a] filter p [] = [] filter p (x:xs) = if p x then x : filter p xs else filter p xs iterate :: (a -> a) -> a -> [a] iterate f x = x : iterate f (f x) take :: Int -> [a] -> [a] take 0 _ = [] take _ [] = [] take n (x:xs) = x : take (n-1) xs
非決定性のインタプリタ(4.12)で次の関数の値を計算してください。
letrec fact = fn n -> if n<=0 then 1 else n*fact(amb n-1 or n-2) in fact 9
締切は1月16日の授業時間です。