関数型プログラミング言語Haskell Part8 at TECH
[2ch|▼Menu]
446:デフォルトの名無しさん
08/01/16 19:00:45
>>445
なぜか$!に慣れないのでseqを使ってるけど

toBaseN_loop_case :: Integer -> Integer -> [Integer]
toBaseN_loop_case n 0 = [0]
toBaseN_loop_case n x = f x []
  where
    f 0 ds = ds
    f x ds = case divMod x n of
      (r, q) -> f r (q:ds)

toBaseN_loop :: Integer -> Integer -> [Integer]
toBaseN_loop n 0 = [0]
toBaseN_loop n x = f x []
  where
    f 0 ds = ds
    f x ds = let q = div x n; r = div x n in
      q `seq` r `seq` f r (q:ds)


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5324日前に更新/201 KB
担当:undef