いろんな言語で宿題スレat TECH
いろんな言語で宿題スレ - 暇つぶし2ch190:デフォルトの名無しさん
09/06/16 15:29:48
>>180
main = getLine >>= return . scanl1 (+) . map (read :: String -> Int) . take 10 . words >>= \t -> if null t then return () else print t >> main

>>187
import Data.List (transpose)

type Matrix = [[Int]]

fold2l :: (a -> b -> c -> a) -> a -> [b] -> [c] -> a
fold2l f a [] _ = a
fold2l f a _ [] = a
fold2l f a (x:xs) (y:ys) = fold2l f (f a x y) xs ys

mult :: Matrix -> Matrix -> Matrix
mult xss yss = mult' xss $ transpose yss
where
mult' :: Matrix -> Matrix -> Matrix
mult' [] _ = []
mult' (xs:xss) yss = map (\ys -> fold2l (\s x y -> s + x*y) 0 xs ys) yss : mult' xss yss


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch