YAMAGUCHI::weblog::Haskell

2006-07-07 (Fri)

[]ふつうのHaskellプログラミング 第8章 練習問題

  • lrstrip.hs
lrstrip :: String -> String
lrstrip = rstrip . lstrip
  • tail2.hs
main = do cs <- getContents
          putStr $ lastNLines 10 cs

lastNLines :: Int -> String -> String
lastNLines n = unlines . reverse . take n . reverse . lines 
  • fgrep.hs
fgrep :: String -> String -> String
fgrep pattern = unlines . filter (match pattern) . lines

match :: String -> String -> Bool
match pattern = any (pattern `isPrefixOf`) . tails

最後の問題は第8章内でやってるじゃん。問題解いてる途中で気が付いた。だけど、ポイントフリースタイルは慣れるまで上手く書けそうにないなぁ。

AnandAnand2013/03/29 13:31BS low - rtaioanltiy high! Really good answer!

neqlbohvouneqlbohvou2013/03/30 14:157ceFsh <a href="http://eqytygdesrqg.com/">eqytygdesrqg</a>

exvwalmvvexvwalmvv2013/04/01 10:366nClff , [url=http://hsowvpfdwrtb.com/]hsowvpfdwrtb[/url], [link=http://xdddzuwxqkoa.com/]xdddzuwxqkoa[/link], http://zemaomumgbnr.com/

2006-07-06 (Thu)

[]ふつうのHaskellプログラミング 第8章 練習問題

たしかにポイントフリースタイルで書くとすっきりする気がする。ただ綺麗に書ける自信があまりない。

  • lstrip.hs
lstrip :: String -> String
lstrip = dropWhile (== ' ')
  • rstrip.hs
rstrip :: String -> String
rstrip = reverse . lstrip . reverse

[]ふつうのHaskellプログラミング 第7章 練習問題

  • fold.hs
foldCol = 61

main = do cs <- getContents
          putStr $ unlines $ map foldLineAt $ lines cs

foldLineAt :: String -> String
foldLineAt cs = case snd (splitAt foldCol cs) of
                  [] -> cs
                  (c1:cs1) -> if length cs1 >= (foldCol - 1)
                              then foldLineAt cs1
                              else fst (splitAt foldCol cs) ++ "\n" ++ snd (splitAt foldCol cs)

どうもソースが汚いなぁ。もっと綺麗に書けるように練習しないと。どうも条件分岐の処理がへたくそな気がする。

glory hole bitchesglory hole bitches2007/07/12 17:58 <a href="http://www.huy0803.info/fucking.html">fucking gallery</a> <a href="http://www.huy0803.info/glamour.html">british glamour girls</a> <a href="http://www.huy0803.info/gag.html">gage earrings</a> <a href="http://www.huy0803.info/gape.html">water gap</a> <a href="http://www.huy0803.info/free_2.html">free psychology journal articles porn anxiety treatment</a> <a href="http://www.huy0803.info/free_4.html">free christmas card design</a> <a href="http://www.huy0803.info/gay_1.html">gay bars in boston</a> <a href="http://www.huy0803.info/girl_1.html">girl mask</a> <a href="http://www.huy0803.info/free_3.html">submit your website to 400 search engines for free</a> <a href="http://www.huy0803.info/fucked.html">blonde face fucked</a> [url="http://www.huy0803.info/fucking.html"]fucking gallery[/url] [url="http://www.huy0803.info/glamour.html"]british glamour girls[/url] [url="http://www.huy0803.info/gag.html"]gage earrings[/url] [url="http://www.huy0803.info/gape.html"]water gap[/url] [url="http://www.huy0803.info/free_2.html"]free psychology journal articles porn anxiety treatment[/url] [url="http://www.huy0803.info/free_4.html"]free christmas card design[/url] [url="http://www.huy0803.info/gay_1.html"]gay bars in boston[/url] [url="http://www.huy0803.info/girl_1.html"]girl mask[/url] [url="http://www.huy0803.info/free_3.html"]submit your website to 400 search engines for free[/url] [url="http://www.huy0803.info/fucked.html"]blonde face fucked[/url]

google satellite picgoogle satellite pic2007/07/25 00:30<a href="http://www.yhobqwny.cn/page96.html">hot thong gallery</a> hot thong gallery,<a href="http://www.yhobqwny.cn/page68.html">german pogo stick</a> german pogo stick,<a href="http://www.yhobqwny.cn/page69.html">kids next door hentai</a> kids next door hentai,<a href="http://www.yhobqwny.cn/page58.html">2pac clothing</a> 2pac clothing,<a href="http://www.yhobqwny.cn/page79.html">bed of razors mp3</a> bed of razors mp3,<a href="http://www.yhobqwny.cn/page63.html">bart and lisa simpsons having sex</a> bart and lisa simpsons having sex,<a href="http://www.yhobqwny.cn/page85.html">home depot lowes inventory headings</a> home depot lowes inventory headings,<a href="http://www.yhobqwny.cn/page72.html">bellsouth news server</a> bellsouth news server,<a href="http://www.yhobqwny.cn/page75.html">funny sports team names</a> funny sports team names,<a href="http://www.yhobqwny.cn/page80.html">juniper hills golf course</a> juniper hills golf course,

angel food bakeryangel food bakery2007/07/25 08:38<a href="http://www.pxwjfhyx.cn/page38.html">georgia camping and rv show</a> georgia camping and rv show,<a href="http://www.pxwjfhyx.cn/page17.html">ford f250 pickup truck</a> ford f250 pickup truck,<a href="http://www.pxwjfhyx.cn/page15.html">advanced antioxidant solgar</a> advanced antioxidant solgar,<a href="http://www.pxwjfhyx.cn/page43.html">data center manager resume</a> data center manager resume,<a href="http://www.pxwjfhyx.cn/page35.html">incest mom and son cartoons comics</a> incest mom and son cartoons comics,<a href="http://www.pxwjfhyx.cn/page18.html">bratz bedroom</a> bratz bedroom,<a href="http://www.pxwjfhyx.cn/page38.html">1919 cost movie show ticket</a> 1919 cost movie show ticket,<a href="http://www.pxwjfhyx.cn/page29.html">alexis dziena broken flowers nude vidcaps</a> alexis dziena broken flowers nude vidcaps,<a href="http://www.pxwjfhyx.cn/page38.html">brock lesnar vs big show</a> brock lesnar vs big show,<a href="http://www.pxwjfhyx.cn/page9.html">accounting software programs</a> accounting software programs,

cunts and titscunts and tits2007/07/26 05:31<a href="http://www.gbneombg.cn/page85.html">dow jones aig commodity index</a> dow jones aig commodity index,<a href="http://www.gbneombg.cn/page54.html">daisy ascii art flowers</a> daisy ascii art flowers,<a href="http://www.gbneombg.cn/page76.html">cheap verizon wireless cell phones</a> cheap verizon wireless cell phones,<a href="http://www.gbneombg.cn/page58.html">boise id pet stores</a> boise id pet stores,<a href="http://www.gbneombg.cn/page78.html">gossip on jessica simpson wearing nick lachey's wedding ring</a> gossip on jessica simpson wearing nick lachey's wedding ring,<a href="http://www.gbneombg.cn/page61.html">first anal sex movie</a> first anal sex movie,<a href="http://www.gbneombg.cn/page74.html">joey new york skin care</a> joey new york skin care,<a href="http://www.gbneombg.cn/page68.html">australian dog names</a> australian dog names,<a href="http://www.gbneombg.cn/page65.html">bridal honeymoon lingerie</a> bridal honeymoon lingerie,<a href="http://www.gbneombg.cn/page64.html">big tits and bras</a> big tits and bras,

el me mintio lyricsel me mintio lyrics2007/07/26 06:18<a href="http://www.evazoimy.cn/page94.html">bon jovi ill be there for you lyrics</a> bon jovi ill be there for you lyrics,<a href="http://www.evazoimy.cn/page59.html">books written by nietzsche online</a> books written by nietzsche online,<a href="http://www.evazoimy.cn/page57.html">basic trigonometry</a> basic trigonometry,<a href="http://www.evazoimy.cn/page69.html">kansas city discount real estate commission</a> kansas city discount real estate commission,<a href="http://www.evazoimy.cn/page68.html">kurt cobain videos and pictures</a> kurt cobain videos and pictures,<a href="http://www.evazoimy.cn/page83.html">hentai art gallery</a> hentai art gallery,<a href="http://www.evazoimy.cn/page72.html">center finance national new orleans</a> center finance national new orleans,<a href="http://www.evazoimy.cn/page65.html">free money making guide runescape</a> free money making guide runescape,<a href="http://www.evazoimy.cn/page92.html">handheld porn psp</a> handheld porn psp,<a href="http://www.evazoimy.cn/page92.html">game cheats for the psp</a> game cheats for the psp,

anthrax wikipediaanthrax wikipedia2007/07/26 09:19<a href="http://www.vllaxicr.cn/page87.html">basic math test for employment</a> basic math test for employment,<a href="http://www.vllaxicr.cn/page62.html">honda civic si reviews</a> honda civic si reviews,<a href="http://www.vllaxicr.cn/page55.html">dover downs nascar ticket</a> dover downs nascar ticket,<a href="http://www.vllaxicr.cn/page95.html">3m adhesive rear view mirror</a> 3m adhesive rear view mirror,<a href="http://www.vllaxicr.cn/page65.html">internet mail servers</a> internet mail servers,<a href="http://www.vllaxicr.cn/page65.html">internet voice mail</a> internet voice mail,<a href="http://www.vllaxicr.cn/page90.html">google lawsuits</a> google lawsuits,<a href="http://www.vllaxicr.cn/page93.html">bbw clubs</a> bbw clubs,<a href="http://www.vllaxicr.cn/page68.html">girls kissing in movies</a> girls kissing in movies,<a href="http://www.vllaxicr.cn/page57.html">code hilton hotel promotion</a> code hilton hotel promotion,

kinky blowjobskinky blowjobs2007/07/27 07:02<a href="http://www.zenfuiqi.cn/page77.html">161 cd dvd qsi rw sbw</a> 161 cd dvd qsi rw sbw,<a href="http://www.zenfuiqi.cn/page65.html">hotel equatorial</a> hotel equatorial,<a href="http://www.zenfuiqi.cn/page90.html">applescript indesign save to replacing yes</a> applescript indesign save to replacing yes,<a href="http://www.zenfuiqi.cn/page68.html">karst sports</a> karst sports,<a href="http://www.zenfuiqi.cn/page82.html">hiv from licking vagina</a> hiv from licking vagina,<a href="http://www.zenfuiqi.cn/page67.html">aerial view of brixton</a> aerial view of brixton,<a href="http://www.zenfuiqi.cn/page97.html">installing stereo jeep laredo</a> installing stereo jeep laredo,<a href="http://www.zenfuiqi.cn/page58.html">home sitting</a> home sitting,<a href="http://www.zenfuiqi.cn/page59.html">connect cell phone to laptop</a> connect cell phone to laptop,<a href="http://www.zenfuiqi.cn/page58.html">home made bomb recipes</a> home made bomb recipes,

blowjobs kneelingblowjobs kneeling2007/07/27 09:21<a href="http://www.qzyxqnwt.cn/page68.html">definition meta model</a> definition meta model,<a href="http://www.qzyxqnwt.cn/page94.html">anal sore</a> anal sore,<a href="http://www.qzyxqnwt.cn/page94.html">hetero anal</a> hetero anal,<a href="http://www.qzyxqnwt.cn/page60.html">ga jeep dealers</a> ga jeep dealers,<a href="http://www.qzyxqnwt.cn/page97.html">free email leads no spam</a> free email leads no spam,<a href="http://www.qzyxqnwt.cn/page95.html">horse creek chert</a> horse creek chert,<a href="http://www.qzyxqnwt.cn/page59.html">kingdom hearts 2 them music</a> kingdom hearts 2 them music,<a href="http://www.qzyxqnwt.cn/page70.html">anime manga learn draw</a> anime manga learn draw,<a href="http://www.qzyxqnwt.cn/page68.html">engine meta mp3 search</a> engine meta mp3 search,<a href="http://www.qzyxqnwt.cn/page83.html">free mercedes benz 290gd 461 parts manual</a> free mercedes benz 290gd 461 parts manual,

TuiqrskTuiqrsk2007/07/29 21:09<a href= http://mlm.laplanezarde.info/credit-card/site_map.html >card citi credit</a> [url=http://mlm.laplanezarde.info/credit-card/site_map.html]card citi credit[/url]

actiontitleactiontitle2007/08/01 07:56<a href="httpwwwlefnytjucnpage60html">nece313photretrieval</a> nece313photretrieval,<a href="httpwwwlefnytjucnpage48html">shootingpreservenewyorkcandor</a> shootingpreservenewyorkcandor,<a href="httpwwwlefnytjucnpage44html">_1webdeaccueilderevendeur</a> _1webdeaccueilderevendeur,<a href="httpwwwlefnytjucnpage57html">triangularprismpics</a> triangularprismpics,<a href="httpwwwlefnytjucnpage64html">samanthaluvcoxfootball</a> samanthaluvcoxfootball,<a href="httpwwwlefnytjucnpage48html">agriculturalpreserveskerncountydelano</a> agriculturalpreserveskerncountydelano,<a href="httpwwwlefnytjucnpage61html">polkcountytaxsales</a> polkcountytaxsales,<a href="httpwwwlefnytjucnpage56html">kinggeorgeiiihobbies</a> kinggeorgeiiihobbies,<a href="httpwwwlefnytjucnpage62html">adollhousebyhenrikibsenimagery</a> adollhousebyhenrikibsenimagery,<a href="httpwwwlefnytjucnpage54html">cecilsworlddecember222006</a> cecilsworlddecember222006,

LuisLuis2013/03/31 19:47Economies are in dire srtiats, but I can count on this!

nbhqpznbhqpz2013/04/01 18:54zqLH6z <a href="http://syawjzbwidjh.com/">syawjzbwidjh</a>

fpdywrufpdywru2013/04/02 01:419gFuc9 , [url=http://rynqihzbbypc.com/]rynqihzbbypc[/url], [link=http://zptrnttjylwq.com/]zptrnttjylwq[/link], http://eslmzpnrrpke.com/

caizwtmcwwqcaizwtmcwwq2013/04/04 19:46y5kTAm , [url=http://vkjdcjaymmnb.com/]vkjdcjaymmnb[/url], [link=http://jlourjssxyzw.com/]jlourjssxyzw[/link], http://fkakxfnznrge.com/

2006-07-01 (Sat)

[]ふつうのHaskellプログラミング 第4章 練習問題

  • sort.hs
import System
import List

main = do cs <- getContents
          putStr $ sortLines cs

sortLines :: String -> String
sortLines cs = unlines $ map sort $ lines cs
  • uniq.hs
import System
import List

main = do cs <- getContents
          putStr $ groupLines cs

groupLines :: String -> String
groupLines cs = unlines $ map head $ group $ lines cs

uniq.hsに関してはまとめるだけなのか、まとめてから表示するのか微妙だったけど、とりあえず今までが全部コンソールに表示系のプログラムだったのでそうしてみた。

ReenuReenu2012/05/03 08:21Thanks for spending time on the computer (writnig) so others don't have to.

dljtdrgdljtdrg2012/05/03 12:14PsyRix <a href="http://aarqgzietjib.com/">aarqgzietjib</a>

hwsegukshwseguks2012/05/04 09:30Yjf4LA , [url=http://nxmfzgrqodna.com/]nxmfzgrqodna[/url], [link=http://qztkcxzosjis.com/]qztkcxzosjis[/link], http://sjzfcpmsqwot.com/

kyfadhukyfadhu2012/05/05 11:58eNPy2h <a href="http://aqqqsndbgzfu.com/">aqqqsndbgzfu</a>

kyfadhukyfadhu2012/05/05 11:59eNPy2h <a href="http://aqqqsndbgzfu.com/">aqqqsndbgzfu</a>

xvfwykuvxvfwykuv2012/05/05 15:5383WpnE , [url=http://dhsuztlxafzp.com/]dhsuztlxafzp[/url], [link=http://rhqfvrmxlfku.com/]rhqfvrmxlfku[/link], http://wwvlsjhuifnx.com/

2006-06-30 (Fri)

[]ふつうのHaskellプログラミング 第3章 練習問題

expandA関数の定義の部分で"expandA"を"expadnA"とミスタイプしちゃったのにコンパイル通っちゃった。どうしてだろう?とりあえず自分の解答。

main = do cs <- getContents
          putStr $ expand cs

expand :: String -> String
expand cs = map expandA cs

expandA :: Char -> Char
expandA 'A' = 'a'
expandA 'a' = 'A'
expandA c = c

[]ふつうのHaskellプログラミング 第2章 練習問題 14:13

自分が作ってみた解答。こんな感じでいいんでしょうか?

  • countbyte.hs
main = do cs <- getContents
          print $ length cs
  • countword
main = do cs <- getContents
          print $ length $ words cs

LoreLore2012/01/06 17:09Redanig this makes my decisions easier than taking candy from a baby.

shorhehbxstshorhehbxst2012/01/06 19:09VpEzM1 <a href="http://yyynihwwytnj.com/">yyynihwwytnj</a>

cjbgummsycjbgummsy2012/01/09 23:25a3S9xV <a href="http://dheczxdjvgqa.com/">dheczxdjvgqa</a>

nejmjrqiifwnejmjrqiifw2012/01/11 03:52ynbruv , [url=http://uqydfvfrntrb.com/]uqydfvfrntrb[/url], [link=http://bojfcrksbnlo.com/]bojfcrksbnlo[/link], http://mmncfgiuqmor.com/

2006-06-21 (Wed)

[]始めてみようかと&書籍購入

研究会前とか含めいろんな締切が近いから現実逃避にいろいろ始めたくなるお年頃。というわけで前々から気になっていたHaskellを始めてみようかと。

とりあえずGHCがよいのでは無いかということでGHCを入れてみる所存です。だれか一緒にHaskellする人募集中。nvacaさんはすでにやってますが。あとこの本買いたいんだよねぇ。

入門Haskell―はじめて学ぶ関数型言語

入門Haskell―はじめて学ぶ関数型言語

で、買いました。早速すこしずつ読んでいこう。