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 = putStrLn "Hello World" |
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
{-# LANGUAGE OverloadedStrings #-} | |
import Data.ByteString.Char8 (unpack) | |
import Network.Wai | |
import Network.HTTP.Types (status200) | |
import Network.Wai.Handler.Warp (run) | |
application :: Application | |
application req respond = case rawPathInfo req of | |
"/" -> respond $ responseFile status200 [("Content-Type", "text/html")] "index.html" Nothing | |
p -> respond $ responseFile status200 [] p' Nothing |
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
{-# LANGUAGE OverloadedStrings #-} | |
import qualified Data.ByteString as SB | |
import qualified Data.ByteString.Char8 as SBC | |
import qualified Data.ByteString.Lazy as LB | |
import qualified Data.ByteString.Lazy.Char8 as LBC | |
import qualified Data.Text as ST | |
import qualified Data.Text.Encoding as STE | |
import qualified Data.Text.Lazy as LT | |
import qualified Data.Text.Lazy.Encoding as LTE |
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
{-# LANGUAGE OverloadedStrings #-} | |
import Text.XML.Cursor | |
import Text.HTML.DOM (parseLBS) | |
import Network.HTTP.Conduit | |
import qualified Data.Text as T | |
import qualified Data.Text.IO as T | |
main :: IO () | |
main = do | |
doc <- parseLBS <$> simpleHttp "http://www.ishiy.xyz/archive.html" |
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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
import Web.Authenticate.OAuth | |
import Data.Text (Text) | |
import qualified Data.Text.IO as T | |
import Data.Aeson | |
import GHC.Generics | |
import Network.HTTP.Conduit | |
myOAuth :: OAuth |
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
{-# LANGUAGE OverloadedStrings #-} | |
import Web.Authenticate.OAuth | |
import Data.ByteString (ByteString) | |
import Data.Text.Encoding (encodeUtf8) | |
import Network.HTTP.Conduit | |
myOAuth :: OAuth | |
myOAuth = newOAuth { oauthServerName = "api.twitter.com" | |
, oauthConsumerKey = "Your Consumer Key" | |
, oauthConsumerSecret = "Your Consumer Secret" |
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 Data.List (foldl') | |
-- 長方形近似 | |
integral :: Double -> Double -> Double -> (Double -> Double) -> Double | |
integral a b dx f = foldl' (+) 0 $ map ((dx *) . f) xs | |
where xs = [a + dx*x| x <- [0..(b-a)/dx]] | |
-- 台形近似 | |
integral2 :: Double -> Double -> Double -> (Double -> Double) -> Double | |
integral2 a b dx f = foldl' (+) 0 $ map (\(y1,y2) -> dx * (y1 + y2) / 2) $ zip ys (tail 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 System.Random | |
import Data.List | |
main :: IO () | |
main = do | |
xGen <- getStdGen | |
yGen <- newStdGen | |
let n = 100000 | |
let xs = take n $ randomRs (0,1) xGen | |
ys = take n $ randomRs (0,1) yGen |
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 Data.List (unfoldr) | |
-- dy/dx = f | |
f x y = - a * y | |
-- パラメータ | |
a = 1 | |
-- 区間と初期値 | |
x0 = 0 | |
x1 = 5 | |
y0 = 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
import Data.List (unfoldr) | |
-- dy/dx = f | |
f x y = - a * y | |
-- パラメータ | |
a = 1 | |
-- 区間と初期値 | |
x0 = 0 | |
x1 = 5 | |
y0 = 1 |
OlderNewer