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
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
(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
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
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
f . g $ x ≡ f $ g $ x -- (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 AbstractSyntax where | |
-- | | |
-- 構文 | |
-- | |
data Exp = Int Integer | |
| Var String | |
| Sub Exp Exp | |
| If Exp Exp Exp Exp | |
| Fun String Exp |
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 EnvironmentClos where | |
import AbstractSyntax | |
-- | | |
-- 環境 | |
type Env = [(String, Value)] | |
emptyEnv :: Env | |
emptyEnv = [] |
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 Environment where | |
import Value | |
-- | | |
-- 環境 | |
-- | |
type Env = [(String, Value)] | |
emptyEnv :: Env |
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
sumUsingFold :: Num a => [a] -> a | |
sumUsingFold = foldr (+) 0 | |
sumUsingFold' :: Num a => [a] -> a | |
sumUsingFold' = foldl' (+) 0 |