[1..100]>>=pen #4481(2007/11/29 11:11 GMT) [ Haskell ] Rating2/2=1.00
高階関数を使って。 書き換えた部分のみ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import List import Maybe count pred xs = length $ filter pred xs countDigs' radix ks = map sum $ transpose $ map (countDigs radix) ks combListsS n lim = sequence $ replicate n [1..lim-1] combLists'' n = [1..] >>= combListsM n check radix xss = mapMaybe f xss where f xs = if xs' == cs then Just xs' else Nothing where xs' = reverse xs cs = map (+1) $ countDigs' radix xs' showResult radix xs = ("この文は" ++) $ (++ "あります。") $ concat $ intersperse ", " $ map ct [0..radix-1] where ct i = show i ++ "が" ++ showIntAtBase radix intToDigit (xs!!i) "個"
Rating2/2=1.00-0+
[ reply ]
[1..100]>>=pen
#4481()
[
Haskell
]
Rating2/2=1.00
Rating2/2=1.00-0+