- 関数型プログラミング言語Haskell Part27_©2ch.net
35 :デフォルトの名無しさん[sage]:2015/01/12(月) 10:01:32.94 ID:SO+1IXbJ - 途中で何を求めてるのか、分かりやすさ重視だとこんな感じ?
saturateSimple :: HaveSize a => Int -> [a] -> (Int, [a]) saturateSimple _ [] = (0, []) saturateSimple n xs | 0 <= n = (sumSize, taked) | otherwise = (0, []) where sumSize = sum $ map size taked taked | Just takeRange' <- takeRange = take takeRange' xs | otherwise = xs takeRange = findIndex (>n) sizedList sizedList = scanl1 (+) $ map size xs
|