Skip to content

Instantly share code, notes, and snippets.

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
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
(foldr (⊕) z .) . zipWith (⊗)
foldr (⊛) (const z)
where
(x ⊛ k) [] = z
(x ⊛ k) (y:ys) = (x ⊗ y) ⊕ k ys
@nobsun
nobsun / excelColns.hs
Created August 8, 2014 00:23
Excelカラム名の生成(改) ref: http://qiita.com/nobsun/items/fbb9bcda0bf5c65b4e8d
import Control.Monad (liftM2)
excelColns :: [String]
excelColns = concat $ tail $ iterate (liftM2 (:) ['A'..'Z']) [""]
@nobsun
nobsun / file0.txt
Last active July 1, 2019 21:52
Haskellプログラミングのコツのようなもの ref: https://qiita.com/nobsun/items/ed33c22203734e706e9b
main = interact gonyo
@nobsun
nobsun / file0.txt
Created August 11, 2014 06:53
Haskellプログラミングのコツのようなもの(その2) ref: http://qiita.com/nobsun/items/c16417fdecd7f5c2f9fa
f . g $ x ≡ f $ g $ x -- (1)
@nobsun
nobsun / AbstractSyntax.hs
Last active August 29, 2015 14:14
「関数型プログラミング言語の定義&実装の仕方の例」をHaskellで実装してみた ref: http://qiita.com/nobsun/items/5a88d37745e8d89a154a
module AbstractSyntax where
-- |
-- 構文
--
data Exp = Int Integer
| Var String
| Sub Exp Exp
| If Exp Exp Exp Exp
| Fun String Exp
@nobsun
nobsun / EnvironmetClos
Created January 31, 2015 15:08
「環境とクロージャを用いた、より効率的な関数型プログラミング言語の定義&実装の仕方の例」をHaskellで実装してみた ref: http://qiita.com/nobsun/items/cbb780ffb68634873639
module EnvironmentClos where
import AbstractSyntax
-- |
-- 環境
type Env = [(String, Value)]
emptyEnv :: Env
emptyEnv = []
@nobsun
nobsun / Environment.hs
Last active August 29, 2015 14:14
「環境とクロージャを用いた、より効率的な関数型プログラミング言語の定義&実装の仕方の例」をHaskellで実装してみた(その2) ref: http://qiita.com/nobsun/items/9ef785f88aff3e2cce0d
module Environment where
import Value
-- |
-- 環境
--
type Env = [(String, Value)]
emptyEnv :: Env
@nobsun
nobsun / prob1-sum-using-fold.hs
Last active August 29, 2015 14:24
Haskellでやってみた -- あのプログラミングの5つのお題 ref: http://qiita.com/nobsun/items/0e1da260dd315c7a80ea
sumUsingFold :: Num a => [a] -> a
sumUsingFold = foldr (+) 0
sumUsingFold' :: Num a => [a] -> a
sumUsingFold' = foldl' (+) 0