2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,15 +1,2 @@
|
|||
import Data.List
|
||||
|
||||
xs <+> ys = zipWith (+) xs ys
|
||||
xs <*> ys = sum $ zipWith (*) xs ys
|
||||
|
||||
newtype Mat a = Mat {unMat :: [[a]]} deriving Eq
|
||||
|
||||
instance Show a => Show (Mat a) where
|
||||
show xm = "Mat " ++ show (unMat xm)
|
||||
|
||||
instance Num a => Num (Mat a) where
|
||||
negate xm = Mat $ map (map negate) $ unMat xm
|
||||
xm + ym = Mat $ zipWith (<+>) (unMat xm) (unMat ym)
|
||||
xm * ym = Mat [[xs <*> ys | ys <- transpose $ unMat ym] | xs <- unMat xm]
|
||||
fromInteger n = Mat [[fromInteger n]]
|
||||
fib :: Integer -> Integer
|
||||
fib n = fst $ foldl (\(a, b) _ -> (b, a + b)) (0, 1) [1 .. n]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue