tag:blogger.com,1999:blog-9197115.post1587549740601462123..comments2023-12-04T01:08:41.914+09:00Comments on k16's note: Haskellでプログラムを書くときは、まず関数の型を妄想してHoogleしろk16http://www.blogger.com/profile/02349067627444091120noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-9197115.post-86889000028353927842008-09-11T23:14:00.000+09:002008-09-11T23:14:00.000+09:00show!どうりでx->string的なものがないのか!show!<BR/>どうりでx->string的なものがないのか!k16https://www.blogger.com/profile/02349067627444091120noreply@blogger.comtag:blogger.com,1999:blog-9197115.post-78646250428032734942008-09-11T14:50:00.000+09:002008-09-11T14:50:00.000+09:00nabeatu :: Int -> Stringnabeatu n | n `mod` 3 =...nabeatu :: Int -> String<BR/>nabeatu n | n `mod` 3 == 0 = "aho"<BR/> | elem '3' str = "aho"<BR/> | otherwise = str<BR/> where str = show n<BR/><BR/>main = putStr $ unlines $ map nabeatu [1..40]Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9197115.post-83702730738819654602008-09-11T10:17:00.000+09:002008-09-11T10:17:00.000+09:00ありがとうございます。 > Hayoo!整数型の除算がちゃんとあったんですよね。(/) と m...ありがとうございます。 > Hayoo!<BR/><BR/>整数型の除算がちゃんとあったんですよね。<BR/>(/) と mod が商と剰余だと思い込んでました。<BR/><BR/>それにつけても mapAccumR 最強 :)<BR/>「商と剰余をタプルで返してくれないかな」→「Int -> Int -> (Int, Int) あたりを検索」でうまく divMod を見つけられると、自力でmapAccumR を発動できたのかなあ。k16https://www.blogger.com/profile/02349067627444091120noreply@blogger.comtag:blogger.com,1999:blog-9197115.post-33446694904685221722008-09-11T07:28:00.000+09:002008-09-11T07:28:00.000+09:00Int を n 進の各桁のリストにするにはたとえばData.List.mapAccumR を使って...Int を n 進の各桁のリストにするにはたとえば<BR/>Data.List.mapAccumR を使って<BR/><BR/>rep :: Int -> Int -> [Int]<BR/>rep n i = snd $ mapAccumR divMod i <BR/> $ zipWith const (repeat n) (show i)<BR/><BR/>とか。Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9197115.post-89266646785043944822008-09-11T07:16:00.000+09:002008-09-11T07:16:00.000+09:00fromEnum $ floor $ toEnum n/10というのは単にn `div` 10 でい...fromEnum $ floor $ toEnum n/10<BR/>というのは単に<BR/>n `div` 10 <BR/>でいいですよねAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-9197115.post-11923537503024253642008-09-11T06:47:00.000+09:002008-09-11T06:47:00.000+09:00Yahoo! ならぬ Hayoo! http://holumbus.fh-wedel.de/hayo...Yahoo! ならぬ Hayoo! <BR/>http://holumbus.fh-wedel.de/hayoo/hayoo.htmlnobsunhttps://www.blogger.com/profile/01269290017407022322noreply@blogger.com