petitviolet blog

    haskell (1 posts)

    icon
    Written by petitviolet

    数字の文字列をread使って数字列に変換する

    2015-09-22QiitaHaskell
    やり方read.returnを使って型を指定すれば良い haskellPrelu
    やり方 read . returnを使って型を指定すれば良い haskell Prelude> let n = "123456789" :: String Prelude> n "123456789" Prelude> map return n :: [String] ["1","2","3","4","5","6","7","8","9"] Prelude> map (read . return) n :: [Int] [1,2,3,4,5,6,7,8,9] Prelude> map (read . return) n :: [Float] [1.0,2.0,3.0,4.