1
請問你能幫我跟下面嗎?我有2個數組,我需要合併成一個數組數組。下面的代碼不會合並,但它會創建一個笛卡爾...haskell:將兩個數組合併成一個Data array
我想有以下的輸出:
data DataXY = DataXY {
var1 :: String,
var2 :: String
} deriving (Eq, Show)
parse :: [DataXY]
parse = x
where
x = [DataXY v1 v2 | v1 <- arr1, v2 <- arr2]
where
arr1 = ["x1", "x2", "x3"]
arr2 = ["y1", "y2", "y3"]
感謝
DataXY {var1 = "x1", var2 = "y1"},
DataXY {var1 = "x2", var2 = "y2"},
DataXY {var1 = "x3", var2 = "y3"}
---代碼, 米。