関数型プログラミング言語Haskell Part8at TECH
関数型プログラミング言語Haskell Part8 - 暇つぶし2ch446:デフォルトの名無しさん
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