• 追加された行はこの色です。
  • 削除された行はこの色です。
[[ネタ記録庫/Haskell]]
#contents

* StateT [#x763ddb2]
これは、permutationを返す関数:
 permutation' :: [[Int]] -> Int -> [Int] -> [[Int]]
 permutation' result 0 _ = result
 permutation' result n cand =
     do a <- cand
        permutation' (map (a:) result) (n-1) [x|x<-cand,x/=a]

使い方
 permutation' [[]] [1,2,3] 2
のように使う。

これをStateTを使ってわざと分かりにくくしてみる:

 permutation :: [[Int]] -> Int -> StateT [Int] [] [[Int]]
 permutation result 0 = return result
 permutation result n =
     do cand <- get
        a <- lift cand
        put [x|x<-cand,x/=a]
        permutation (map (a:) result) (n-1) 

これは
 runStateT (permutation [[]] 2) [1,2,3]

のように使う。
- Thx. 勉強になります。 -- [[げんま]] &new{2007-04-24 (火) 12:45:05};
- 使い方は、permutation' [[]] 2 [1,2,3]  --  &new{2008-07-10 (木) 22:43:25};
- ではないでしょうか? <-元職業プログラマ --  &new{2008-07-10 (木) 22:46:11};
- Very Nice Site! Thanx!http://excellent-credit-card.blogspot.com -- [[badcredit cards]] &new{2008-08-13 (水) 07:14:53};
- MOWeUl ligh29d9F4CsjK0A -- [[darry]] &new{2008-08-27 (水) 13:34:27};
- IKGDcrSLVLyseNgCGeK -- [[wpnyyazcdfp]] &new{2008-09-23 (火) 10:35:57};

#comment

*HaskellでWIKI [#x4eef27a]
書いてみました。いまのところ日本語は使えません。
http://icecs.ice.nuie.nagoya-u.ac.jp/~h043078b/wiki.cgi

* History of Haskell [#z4d010cb]
- http://haskell.org/haskellwiki/History_of_Haskell
- HOPL'07に提出する予定の論文の、ドラフトだそうです。

* HaskellでOS。 [#s0a682d7]
http://www.cse.ogi.edu/~hallgren/House/ -- [[源馬]] &new{2006-07-04 (火) 16:16:05};

*The Evolution of a Haskell Programmer [#ga1c48ba]
[[The Evolution of a Haskell Programmer:http://www.willamette.edu/~fruehr/haskell/evolution.html]] かなりハイレベルにバカやってる感じ
- バカだ〜!fold関数使うまではわかるけど、その後が!まだまだまだまだ続くし。 -- [[げんま]] &new{2006-08-12 (土) 10:35:43};
- インタプリタを作って階乗計算させたり,型クラスを使ったテクニックなんかもあるので分かると結構良いかも。 -- [[けいご]] &new{2006-08-12 (土) 15:27:52};

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS