m = [[1,0,0],[2,-3,0],[4,5]]
t all@(x:xs) = let (m, n) = (length all, length x) in all (==n) (map length all)
命令:
t m
给出:
Couldn't match expected type `(Int -> Bool) -> [Int] -> t'
against inferred type `[[a]]'
In the expression: all (== n) (map length all)
In the expression:
let (m, n) = (length all, length x) in all (== n) (map length all)
In the definition of `t':
t (all@(x : xs))
= let (m, n) = ... in all (== n) (map length all)
ç”案 0 :(得分:4)
您将å称all
ç»‘å®šåˆ°æ•´ä¸ªåˆ—è¡¨ï¼Œå› æ¤å‰å¥å‡½æ•°all
ä¸å†å¯è§ã€‚选择其他åç§°ï¼Œæˆ–åˆ é™¤all@
,然åŽä½¿ç”¨let (m, n) = (length xs + 1, ...)
或类似内容。
ç›¸å…³ï¼šä½ ä¸ºä»€ä¹ˆè¦è®¡ç®—length all
ï¼Ÿä½ ä¸è¦åœ¨ä»»ä½•åœ°æ–¹ä½¿ç”¨å®ƒã€‚
ç”案 1 :(得分:4)
åŽŸå› æ˜¯ï¼Œæ‚¨å°†ç¬¦å·all
é‡æ–°å®šä¹‰ä¸ºt
çš„å‚æ•°ã€‚å› æ¤ï¼Œæœ¬åœ°all
会影å“全局all
,并且您会收到æ¤é”™è¯¯ã€‚作为解决方案,请å°è¯•ä¸ºæ‚¨çš„本地all
æä¾›å¦ä¸€ä¸ªå称。