行列のcolumn数を計算する
型
code:hs
cols :: a -> Int
code:hs
cols (cs:css) = length css
code:hs
cols css = length (head css) -1
code:hs
cols css = if null css then 0 else length $ head css
code:hs
import GHC.Exts (the)
cols = the . map length
与えられたリストの要素数が全て同じであることも検査する
検査に失敗したら実行時エラーだが