Haskell
æ¨æ¥ã®ã³ãã¹ã¿ã®ä¼ã§ã³ã¢ããã®èª¬æããããReaderã³ã¢ããï¼å¤§åå¤æ°ãåç §ããã³ã¢ããï¼ãç»å ´ãããã§ããHaskellã§ã¯Stateã¢ãããReaderã¢ãããã³ã¢ããã§ãªããã¢ããã§å®è£ ããã¦ãã®ã¯ä½æ ï¼ãã¨ãã話ã«ããã®ã¨ãã¯ããMonadStateã¯ã©ã¹ã® get â¦
åç §ï¼ http://d.hatena.ne.jp/m-hiyama/20090801/1249088692 http://d.hatena.ne.jp/bonotake/20090730/1248961849 以ä¸ã¡ã¢ã ã¹ã¿ã³ãã³ã°ã»ã¢ãã Haskellã§ä¸çªã¹ã¿ã³ãã³ã°ã»ã¢ããã£ã½ãã®ã¯ãWriterã¢ããããªã¼ã¨æãã¾ãã*1ãã¨ããã®ã¯ã è¨ç®ã®â¦
ããã¨ãã®åãããããçãä¸ãã£ã¦ããï¼ï¼ï¼ããªããç¹ã«å æ¥å ¥ããããã³ã以éãã²ãããªã®éåã®åã¨ããã¨ãã®åã®å¯¾å¿ãèãã¦ã¦ãµã¨ãããã¢ããã«ãªãããããï¼ãã¨æãç«ã¡ã¾ããã 以ä¸åèï¼ ããã¨ãã®åã«ãããå ¨åå°ã¨ååï¼ï¼åçï¼ - ãâ¦
æ²é¡ã®ä¼ï¼å¥åï¼ç½ç³ããã質åæ»ãã«ãããã®ä¼ï¼ã®å 容ã«ã¤ãã¦ãã¢ã³ã±ã¼ãå§ãã¾ãããç¹ã«åå å¸æã®æ¹ã¯ãååãããããé¡ããã¾ããâã¢ã³ã±ã¼ããã¼ã¸ ãã¡ãããåå å¸æã§ãªãæ¹ãå¿åå¯è½ã§ããã¾ããæ親ä¼ãåå åéå§ãã¾ãããæ親ä¼ã ãã®â¦
åè«åå¼·ä¼å¾ã®ã¨ã¿è©±ã®ç¶ããåã¬ãã®ä¼æ©æéï¼æ親ä¼ã§è©±ãã¦ã¦ãã¨ããããã¤ãã³ããç«ã¡ä¸ãã¦ã¿ããã¨ã«ãä»ã®ã¨ãããITProã®é£è¼è¨äºãæ¬ç©ã®ããã°ã©ãã¯Haskellã使ããããã¿ã«ãçè ã®shelarcyããï¼a.k.a. ç½ç³ããï¼ãå²ãã§ãªãããããã¨ãâ¦
æ¨æ¥ã®æ¥è¨ã®ç¶ãã§ãåé¢æ°ã®åã追è¨ãããã¨æã£ã¦ããã§ãã⦠*Main> :t g g :: (Num b) => (b, b, b) -> b *Main> :t g1_1 g1_1 :: (Num b) => (b, b) -> b -> b *Main> :t g1_2 g1_2 :: (Integer, Integer) -> Integer -> Integer *Main> :t g2 g2 :: â¦
åç §ï¼ http://d.hatena.ne.jp/rst76/20090221/1235178786 http://d.hatena.ne.jp/m-hiyama/20090226/1235606901 è¨æ£ãå ¥ãã¦ã¿ãã g (a, b, x) = a * x + b g1_1 (a, b) = \x -> g (a, b, x) g1_2 = curry3 g g2 = curry $ curry3 g ãã ãâ curry3 :: ((â¦
ãã¦ãå§ç¸®æ¹æ³ã«ã¤ãã¦è§¦ããåã«ãid:ku-ma-meããã®ã¨ããã«ãããTâT7ã¾ã§ã®18ã¹ãããããã¡ãã«ãè¼ãã¦ããã¾ããã¤ãã§ã«è¡¨ã«ãã¦ã¿ã¾ããã
ããããããããªãã§ãããããã ã¨ãããã¨ã§ã解çã§ãã ç§ã®ã¯ãåºæ¬çã«ã¯ku-ma-meããã®ã¨åãã§ããã18ã¹ããããä¸çºå¤æã«å§ç¸®ãã¦ã¾ããã§ã以ä¸ã®éããçµæçã«9åå²ã«ãªã£ã¦ã¾ãã å§ç¸®ã®ä»æ¹ã¯ã¾ãå¾ã»ã©ããã¡ãã
é·ããªã£ãã®ã§ãæ°ãã«ã¨ã³ããªã¼èµ·ããã¾ããã 空ã®æ¨ãçæã許ããå ´å㧠ã示ãåé¡ã®è§£çç·¨ã§ããã¨ã¯ããããªãªã¸ãã«ã®è§£çãã¾ã å ¬éãã¦ãªãã®ã§ãä¸éå端ãªè§£èª¬ã«ãªã£ã¦ã¾ããã å ã®ã¨ã³ããªã¼ã¯ãã¡ãã
seven trees ã®åé¡ãç§ã解ãã¦ã¿ã¾ããã以ä¸åèï¼ Seven Treesï¼ããã¯é£ããããºã«ã ãåãæ¥ãç´¹ä» - æªå±±æ£å¹¸ã®ããã¤ã©é£¼è²è¨ Seven Trees - ã¾ããã Seven trees - λx.x K S K ï¼ ã¯ã¦ãª Seven Treesï¼ã¡ããã¨åé¡ãè¿°ã¹ã㨠- æªå±±æ£å¹¸ã®ããã¤â¦
ããä¸åãã£ãã®ã§ããããã£ã¡ã¯ãã¾ãèå³ããããããå人çã«ã ãã¼ã¿ãã¼ã¹ã«ã¯IMDbã¨ã使ãã°ããã®ããªï¼ï¼ãã¾ã«ãããã¨ã³ã¸ã³ã«ä½¿ã£ã¦ããµã¤ãè¦ããã¾ãããAPIã¨ãããç¥ããï¼
天竺ãèµ°ã£ã¦ãå°ä¸éã«ããããªã®ããã¡ãã£ã¨ãã³ãã±ãªã®ã¯ãåå¼ãã è¶ ãã«ã«èã㦠(in Haskell) import List numConcat n = foldr1 (++) $ map show [1..n] main = print $ head $ genericDrop (5100000000 - 1) $ numConcat 999999999 ãããªã®ã«ãªâ¦
ããã¯ãã¼ã¯ã http://oss.timedia.co.jp/show/ossz/oneline/2005-03-09 æè¿ã«ãªã£ã¦.lhsã使ãå§ããã
ãããçµã¨ãã¨ãã¦ã¾ããï¼ã¾ã ãã£ã¡ã¯éææ¥ã§ããï¼ ãã£ã¡ã§ããç 究ã®æ¦è¦ããªãã¨ãªãåºã¾ã£ã¦ãã¨ããããä¸å®å¿ã ã¨ãã«ãåãé¨å±ã®ãå士課ç¨ã®å¦çããããããã¼ã§ããã¦æ足ãé·ããã¶ã£ããã¼ããªæããªã®ã§ãæåã¡ãã£ã¨ããã£ã¦ããã®ã§â¦
æ風åã«å ¥ã£ã¦ãããé ã«æµ®ããã ããã®ãããç´ æ´ãªçåã æ´æ°ãªãå®æ°ã§ã¯æ®éã« ã ãã©ãã«ã«ãã·ã¢ã³éå (CCC) ä¸è¬ã«ãä»»æã®å¯¾è±¡ 㧠ãªã®ã ãããï¼æ®éã«ãããªãããã ããéåã®åãªããã証æã§ãããã ãã©ã ã¤ããæ®éã®ï¼åä»ï¼é¢æ°åè¨èªâ¦
ããªãã è¼ãããã³ãã¬ã¼ãã¢ããã®è¨äºã§ããã åãã¤ã¤ã«ã²ã³ãªè¨èªã®ã»ãã楽ã¡ãã«å®è£ ã§ãã¾ããã©ãæ¬æ¥ã®ã¢ããæ¦å¿µã¯å¼·ãï¼ãã®ãããå¼·ãï¼åãèæ¯ã¨ããå®å¼åã«ãªã£ã¦ãã¾ãã ããããã¨ãããããã¾ãå³å¯ã«æ¸ãã¦ã¾ããã§ããã â» å人çã«â¦
ååã®ã¨ã³ããªã¼ã§ Haskellã§å®éã«ã¢ããæ¸ããããããã©ãä»äºã»ã£ã½ãåºãã¦éãã§ãã¾ãããã ã£ãã®ã§ãèªéã ãããªäºãè¨ã£ã¦ã¾ããããé±æ«ã§ã¡ãã£ã¨æã空ããã®ã§ãã£ã¦ã¿ã¾ãããå ãã¿ã¯ã³ã³ã¨ãã³ã³ã¨ãã ãHaskellã®ãã¢ããæ©æ§ã使ããªâ¦
ããã«ãã®ã話â¦ã¨ç´æ¥é¢ä¿ãããã©ããç¥ããªããã©ãæHaskellã®ã³ã¼ããæ¸ãå§ããé ã2chã§ãããªã³ã¼ããè¦ã¤ãã¾ããã f = flip ((length .) . filter . (. length . filter id) . (==)) . (foldl ((=<<) . (. (return .) . (:)) . (>>=) ) [[]]) . (â¦
ã«ååå ãã¾ããããµã¤ããèªæ¸ä¼ã
å æã®æ¥è¨ã§æ¸ããããã§ãããããã±ã¼ã¸åãã¦å ¬éãã¾ãããï¼ãã¡ãã®ä¸ã®æ¹ï¼ãªããæ°PCã«ç°å¢ç§»ãããããªããã ã£ãã®ã§ããã¿ãã¿ã§ã©ã£ãééãã¦ãªããä¸å®ã§ãããã¨ããããã ã¡ãªã¿ã«ãèªåã¯.xyzzyã«ãããªé¢¨ã«âæ¸ãã¦ã¾ãã ;;; hs-mode + â¦
å¤å¯ä»ããªãã®ã§ããã¼ã£ã¨PCããã£ã¦ãããã¡ãããªãã®ãä½ã£ã¦ãã¾ãã¾ããã ç§ã¯ç´«è¤ããã¨ãã®hs-modeãé©å½ã«ããã£ã¦ä½¿ã£ã¦ããã®ã§ããããã£ã±ãå¦çç³»ã®ã¤ã³ã¿ãã§ã¼ã¹ããã£ãæ¹ããããªãã¨ä»¥åããæã£ã¦ããã¾ãã¦ãã¨ãããã¨ã§ãã¤ã³ã¿ãâ¦
id:sumiiããããã©ãããããã ãã©ãããããå¼µã£ã¦ãã£ããªã³ã¯ãâhttp://www.diku.dk/~andrzej/papers/RLM-abstract.htmlâ¦èªåããã¾psãè¦ãããªãç°å¢ãªã®ã§ï¼ããã¨ããããã¡ã¢ã
ãããã¤ã¾ãæ¨æ¥ã®ã³ã¼ããæ½è±¡åã»ç°¡ç¥åãã¦ã nonDet :: (a -> b) -> [a] -> [b] nonDet f xs = do x <- xs return (f x)ãèããã¨ãf :: a -> b ãã¢ããã«ä¹ã£ãã£ãä¸çã§ããããªå¤ãè¿ãå¾ãã¨è¨ããã¨ï¼ã§ãå ¥åã®xãããããããããªå¤åã£ã¦ãâ¦
ã£ã¦ãããããã¤ã®äºï¼ nonDet :: [Int] -> [Int] -> [Int] nonDet [] _ = [] nonDet _ [] = [] nonDet xs ys = [(x + y)| x <- xs, y <- ys]ã¢ãã風å³ã§æ¸ã㨠nonDet2 :: [Int] -> [Int] -> [Int] nonDet2 [] _ = [] nonDet2 _ [] = [] nonDet2 xs ys = â¦
http://oss.timedia.co.jp/index.fcgi/kahua-web/show/Haskell/SICPãã¤ã誰ãããããããªããã¨æã£ã¦ããããé¢ç½ããã
http://haskell.org/hoogle/ ï¼ã»âã»ï¼ã¤ã¤ï¼ Haskellã«éãããAPIãªãã¡ã¬ã³ã¹ããªãã¨ã³ã¼ãæ¸ããªã人ãªã®ã§ï¼é¢æ°ã®ååãããå¿ãã¦ãã¾ãï¼ãããããã®ã¯ã¨ã¦ãå¬ããã
ååã®æ¥è¨ã®ç¶ããGHCã§ãèªåã®æå ã§ã¡ããã¨éã£ãYã³ã³ããã¼ã¿â y f = f (y f)â¦1è¡ã§æ¸ãã¾ããorz ã¡ãªã¿ã«å㯠*Main> :t y y :: (t -> t) -> tåèã¯ãã®ã¸ãã¨ããã®ã¸ãã大ãã«ãããã ã¤ã§ãã orz orz ï¼ã¦ããåºã¦ãªãæ¹ããããã話é¡ãâ¦ï¼â¦
sumiiããã®æ¥è¨è¦ãªããHaskellã§Yã³ã³ããã¼ã¿æ¸ãã¦ã¿ããã§ããï¼äºå®ä¸ã»ã¼ä¸¸åãï¼ãåãããã¨æã£ãããHugsã§ã¯åããã§ããã©ãGHCï¼ï¼GHCi)ã ã¨ã³ã³ãã¤ã©ãæ¢ã¾ãã¾ããã*1 ããã¯ä½äºï¼ï¼ä¿ºä½ãæªããã¨ãã¦ãã®ï¼æãã¦ã¨ãã人ãâ¦å¯ã¦ãããâ¦
ååã®ã¨ã³ããªã¼ã®ç¶ããªãã§ããã©ãHaskellã«ããarrowã£ã¦ãæ¥æ¬èªã«è¨³ãã人ã¨ãããªããã ãããï¼ æ¥æ¬èªã§ãªãã¨å¼ã¹ã°ãããã§ãããããã¢ãã¼ãï¼ãç¢ãï¼