Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
*Main> transpose [[1,2],[3,4],[5,6]]
|
||||
[[1,3,5],[2,4,6]]
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import Data.Array
|
||||
|
||||
swap (x,y) = (y,x)
|
||||
|
||||
transpArray :: (Ix a, Ix b) => Array (a,b) e -> Array (b,a) e
|
||||
transpArray a = ixmap (swap l, swap u) swap a where
|
||||
(l,u) = bounds a
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
tpose [ms] = [[m] | m <- ms]
|
||||
tpose (ms:mss) = zipWith (:) ms (tpose mss)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import Data.Matrix
|
||||
|
||||
main :: IO ()
|
||||
main = print matrix >> print (transpose matrix)
|
||||
where
|
||||
matrix = fromList 3 4 [1 ..]
|
||||
11
Task/Matrix-transposition/Haskell/matrix-transposition-5.hs
Normal file
11
Task/Matrix-transposition/Haskell/matrix-transposition-5.hs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import Numeric.LinearAlgebra
|
||||
|
||||
a :: Matrix I
|
||||
a = (3><2)
|
||||
[1,2
|
||||
,3,4
|
||||
,5,6]
|
||||
|
||||
main = do
|
||||
print $ a
|
||||
print $ tr a
|
||||
Loading…
Add table
Add a link
Reference in a new issue