行列の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
GHC.Extsのthe関数を使う
code:hs
import GHC.Exts (the)
cols = the . map length
https://hackage.haskell.org/package/base-4.18.1.0/docs/GHC-Exts.html#v:the
与えられたリストの要素数が全て同じであることも検査する
検査に失敗したら実行時エラーだが