RWH p.102 練習問題
1だけ。
import Data.Char (digitToInt) import Data.List (foldl') asInt_fold xs | head xs == '-' = negate $ fold $ tail xs | otherwise = fold xs where fold xs = foldl' step 0 xs step acc x = 10 * acc + digitToInt x
foldl
, foldr
はまだよくわからない。もう少し書いてみないとしっかり掴めそうにないな…