æãã¦ããããã¨ãæå¾ ãã¦æèåæ¢ãã¦ããããã§ã¯ãã¡ãã¡ãªã®ã§ãç解ã§ããã¨ããã¾ã§èãã¦ã¿ãã
åºæ¬ã«ç«ã¡è¿ãã¨ãsequence
ã®ã½ã¼ã¹ã¯æ¬¡ã®ããã«ãªã£ã¦ããã®ããããããããã
sequence ms = foldr k (return []) ms where k m m' = do { x <- m; xs <- m'; return (x:xs) }
ããã»ã©é£ãããã®ã§ã¯ãªããåé¡ã¯k m m'
ã®é¨åã
Maybeã¢ãããIOã¢ãããªããä½ã¨ãªãäºæ³ã¯ã¤ããããããªã¹ã(Listã¢ãã)ã«é©ç¨ããã¨ã©ããªãããåé¡ã
Prelude> let k m m' = do { x <- m; xs <- m'; return (x:xs) } Prelude> k "01" ["0", "1"] ["00","01","10","11"]
ãã®çµæãè¦ãã°ãsequence
ã§ç´ç©ãã§ããã®ã¯ç解ã§ãã(ãã®çµæãç©ã¿éãªã£ã¦ããã®ã ãã)ã
ã§ãããªãã§ããããçµæã«ãªããã ãã?