This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = interact gonyo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad (liftM2) | |
excelColns :: [String] | |
excelColns = concat $ tail $ iterate (liftM2 (:) ['A'..'Z']) [""] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(foldr (⊕) z .) . zipWith (⊗) | |
⇔ | |
foldr (⊛) (const z) | |
where | |
(x ⊛ k) [] = z | |
(x ⊛ k) (y:ys) = (x ⊗ y) ⊕ k ys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssum :: Num a => [a] -> [a] -> a | |
ssum = foldr f (const 0) | |
where | |
f x g [] = 0 | |
f x g (y:ys) = x * y + g ys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Parallel.Strategies | |
x,y :: Int | |
x = repeat 0 !! 1000000000 | |
y = repeat 1 !! 1000000000 | |
foo :: Eval Int | |
foo = do { rpar x; rpar y; return 2 } | |
{- | |
% ghci -v0 rpar.hs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data I a = I {unI :: a} | |
instance Functor I where | |
fmap f (I a) = I (f a) | |
instance Monad I where | |
return = I | |
I x >>= f = f x | |
foo :: [I a] -> I [a] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Applicative | |
import Data.Time | |
import Data.Time.Calendar.OrdinalDate | |
import Data.Time.Calendar.WeekDate | |
import System.Environment | |
main :: IO () | |
main = dispatch =<< getProgName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ghci> :set +s | |
ghci> patternIndex "abbbbcddddeefggg" "eagcdfbe" | |
5578864439 | |
(0.05 secs, 28983792 bytes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
factorial :: Integer -> Integer | |
factorial (n+1) = (n+1) * factorial n | |
factorial 0 = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.List | |
main :: IO () | |
main = putStr | |
$ unlines | |
$ map (intercalate ".") | |
$ map (map reverse) -- 部分文字列反転 | |
$ unravels |