Haskell
shokos Advent Calendar 2012å æ¥ç®ãã»ã¨ãã©Haskell触ã£ããã¨ãªã人åãã§ãã 社å åå¼·ä¼ã§ä½¿ããã¨æã£ã¦ãããã¿ã Haskellã§ãã£ããããæ°åãå®ç¾©ããã¨ããããªãã¾ãã fib = 1:1:zipWith (+) fib (tail fib) ä½ããã£ã¦ããã®ããå¼ã®å·¦å´ãã説â¦
shokos Advent Calendar 2012åæ¥ç®CAã§ãã¨ã³ã ãHaskellã®æ£®ãã¨ãã社å åå¼·ä¼ããã¦ãã¾ãï¼ ã¨ã²ããããHaskellã®æ£®ï¼ from Shoko Sasaki ååã¯ghciã§ã®ã³ãã³ããè²ã 試ãã¦ãããã¾ããã ã¡ããã£ã¨é 延è©ä¾¡ã®èª¬æã¨ãããã¤ã¤ãçµæ§äººãéã¾ã£ã¦â¦
ç°å¢ã¯macãghc7.0.4yesodã¢ããªã±ã¼ã·ã§ã³ã§ãã¢ãããã¼ããããç»åãã¡ã¤ã«ããã¼ã«ã«ã«ä¿åããã¨ãã«ãæ¥æ¬èªãã¡ã¤ã«åã ã¨æååããã¦ãã¾ãåé¡ãçºçãããã©ãããghc7.0.4ã¯æ¥æ¬èªãã¡ã¤ã«åã«å¯¾å¿ãã¦ããªãã£ã½ããHaskell-jaã«è³ªåãæãã¦â¦
Bundleã§ghc-modããããæ¹æ³ Bundleãæã£ã¦ãã $ cd ~/.vim $ git clone http://github.com/gmarik/vundle.git ~/.vim/vundle.git vimrcã«ã¤ã³ã¹ãã¼ã«ããããã®ã追å vimrcã®ãããã«æ¸ã set nocompatible filetype off set rtp+=~/.vim/vundle.git/ â¦
éçºç°å¢ï¼macãghc7.0.4æ°ããä½ã£ãyesodããã¸ã§ã¯ãã§ãcabal installããã¨ä¸è¨ã¨ã©ã¼ãã§ãã Resolving dependencies... Configuring language-javascript-0.4.9... cabal: The program alex version >=3.0 is required but the version found at /usâ¦
Haskellã®webãã¬ã¼ã ã¯ã¼ã¯yesodãããããã¨æã£ããattoparsecã¾ããã®ä¾åé¢ä¿ã§æããã¦ã¤ã³ã¹ãã¼ã«ã§ããã(ã¨ããã©ã¤ãã©ãªã¯attoparsec0.10以ä¸ãå¿ è¦ã ãã©å¥ã®ã©ã¤ãã©ãªã¯0.10æªæºãå¿ è¦ãªã®ã§ç«¶åããã¨ããããªæãã§æããããã¤ã ãã£è¨ãâ¦
é 延è©ä¾¡ãã³ã¶ã¤ã½(^o^)丿 fizz = cycle ["","","fizz"] buzz = cycle ["","","","","buzz"] fizzbuzz = zipWith fb [1..100] $ zipWith (++) fizz buzz where fb n a | a == "" = show n | otherwise = a cycleã¯å¾ªç°ãªã¹ããä½ãé¢æ°ãªã®ã§ãGHCiã§ãªã«ãâ¦
ghc7.0.2utf8-stringãã¤ã³ã¹ãã¼ã«ã ãã¡ãåç § http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string cabal install utf8-string System.IO.UTF8ã®ã¢ã¸ã¥ã¼ã«ãè¦ãã¨ãã ãããIOå¨ããæã£ã¦ããï¼ appendFile hGetLine openBinaryâ¦
æ¥åã§å¿ è¦ã«ãªã£ãã®ã§ãåå¼·ãã¦ãHaskellã§æ¸ãã¦ã¿ãã import Data.List.Split main = do csv <- readFile "./foo.csv" print $ check $ dataList csv --åè¡ã®å é ããªã¹ãåãã dataList :: String -> [String] dataList csv = foldr (\x xs -> (heaâ¦
ï¼ä¸»ã«ç§ã®ã¾ããã§ï¼æµè¡ã£ã¦ããããã¨ãããã¼ãã¼ãªçç±ã§Haskellãåå¼·ä¸ã§ããåç´ã«çãæ¸ãã¦ããããªã¨æãã¾ãã ä¾ãã°ããªã¹ããå¼æ°ã«æ¸¡ãã¦ãå¶æ°ã®è¦ç´ ã ãè¿ãé¢æ°ãªããããã ãã§ãï½ã evenList :: [Int] -> [Int] evenList [] = [] evenâ¦
ãã¡ãã®ã¤ãã³ãã«åå ãã¦ãã¾ãã第0å ã¹ã¿ã¼ãHaskell : ATNDè²ã ããã ãããã§ãææ義ãªæéãããããã¨æã£ã¦ãã¾ãã ã©ãããããã¨ããããã¾ããï¼ããã§åºãããããã話ãæè¸çããã°ã©ãã³ã°ããããã¨ããã¾ããï¼ãããã¯ç¥ããªãã£ããâ¦
Haskellã§Stackãå®è£ ãã¾ããã åå ããäºå®ã ã£ãåå¿è Haskellåå¼·ä¼ç¬¬3å - [PARTAKE]ã®å®¿é¡ã«ãªã£ã¦ãããã¤ã§ãï¼çµå±ãããªãã£ãã®ã ãã©ï¼ data Stack a = Stack [a] deriving (Show) empty :: Stack a empty = Stack [] isEmpty :: Stack a -> Boâ¦
Haskellã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã¨æåã®ããã°ã©ã forMacï¼éªè±¹ï¼Haskell Platformãã¤ã³ã¹ãã¼ã«ãã¾ãã Download Haskellãã£ããæéãããã¾ãããã¤ã³ã¹ãã¼ã«çµãã£ãããã¿ã¼ããã«ã§ GHCi ãèµ·åãã¦ã¿ããï¼ ãããªæãã§è²ã 試ãã¾ããã³ãã³ãã¯åã«â¦