Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1 @@
matI n = [ [fromEnum $ i == j | i <- [1..n]] | j <- [1..n]]

View file

@ -0,0 +1,2 @@
showMat :: [[Int]] -> String
showMat = unlines . map (unwords . map show)

View 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

View file

@ -0,0 +1,4 @@
idMatrix :: Int -> [[Int]]
idMatrix n =
let xs = [1 .. n]
in xs >>= \x -> [xs >>= \y -> [fromEnum (x == y)]]

View 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