Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
1
Task/Identity-matrix/Haskell/identity-matrix-1.hs
Normal file
1
Task/Identity-matrix/Haskell/identity-matrix-1.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
matI n = [ [fromEnum $ i == j | i <- [1..n]] | j <- [1..n]]
|
||||
2
Task/Identity-matrix/Haskell/identity-matrix-2.hs
Normal file
2
Task/Identity-matrix/Haskell/identity-matrix-2.hs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
showMat :: [[Int]] -> String
|
||||
showMat = unlines . map (unwords . map show)
|
||||
10
Task/Identity-matrix/Haskell/identity-matrix-3.hs
Normal file
10
Task/Identity-matrix/Haskell/identity-matrix-3.hs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
*Main> putStr $ showMat $ matId 9
|
||||
1 0 0 0 0 0 0 0 0
|
||||
0 1 0 0 0 0 0 0 0
|
||||
0 0 1 0 0 0 0 0 0
|
||||
0 0 0 1 0 0 0 0 0
|
||||
0 0 0 0 1 0 0 0 0
|
||||
0 0 0 0 0 1 0 0 0
|
||||
0 0 0 0 0 0 1 0 0
|
||||
0 0 0 0 0 0 0 1 0
|
||||
0 0 0 0 0 0 0 0 1
|
||||
4
Task/Identity-matrix/Haskell/identity-matrix-4.hs
Normal file
4
Task/Identity-matrix/Haskell/identity-matrix-4.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
idMatrix :: Int -> [[Int]]
|
||||
idMatrix n =
|
||||
let xs = [1 .. n]
|
||||
in xs >>= \x -> [xs >>= \y -> [fromEnum (x == y)]]
|
||||
7
Task/Identity-matrix/Haskell/identity-matrix-5.hs
Normal file
7
Task/Identity-matrix/Haskell/identity-matrix-5.hs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
idMatrix :: Int -> [[Int]]
|
||||
idMatrix n =
|
||||
let xs = [1 .. n]
|
||||
in (\x -> fromEnum . (x ==) <$> xs) <$> xs
|
||||
|
||||
main :: IO ()
|
||||
main = (putStr . unlines) $ unwords . fmap show <$> idMatrix 5
|
||||
Loading…
Add table
Add a link
Reference in a new issue