- Curl コマンドの基礎
- Curl コマンドでYo API
- Yoall/
- git commit
- OSS commit
- hubotをherokuで動かす
- ssh key 設定
- while true do done
#include <cstdio> | |
#include <ratio> | |
template <typename R, intmax_t N> | |
struct ratio_pow { | |
using prev = typename ratio_pow<R, N-1>::value; | |
using value = std::ratio<R::num * prev::num, R::den * prev::den>; | |
}; | |
template <typename R> |
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
Set Implicit Arguments. | |
Unset Strict Implicit. | |
Require Import Setoids.Setoid Morphisms. | |
Generalizable All Variables. | |
Class Setoid := | |
{ | |
carrier: Type; | |
equal: carrier -> carrier -> Prop; |
When coding financial calculations, it's common to have a variety of numeric values such as Quantity, Price, Amount and so on. In quant finance, these usually refer to the Price observed in the market, a Quantity of shares. A Quantity of shares all traded at a given Price in a given currency will give you an Amount of that currency (the total value of the trade).
It's simple and fun exercise to write the functions you'd need to perform all the correct ways of combining Price, Quantity and Amount. There are a couple of things that don't work as you might expect (e.g., multiplication is ok but you need to think about division semantics.).
Many Haskell tutorials encourage the coder to wrap Double and Int in newtypes like this, so the compiler can help by detecting incorrect combinations of the different types, and so the code documents itself better. e.g.
import System.Random | |
import Control.Monad | |
main :: IO() | |
main = print showKiyoshi | |
getRandomInt :: IO Int | |
getRandomInt = getStdRandom $ randomR (0,1) :: IO Int | |
text :: [String] |
import System.Random | |
main = do | |
gen1 <- getStdGen | |
let rand = getRandom gen1 | |
print . showKiyoshi . getKiyoshi $ rand | |
text :: [String] | |
text = ["zun", "doko", "kiyoshi"] |
löb is a well-known function in Haskell for implementing spreadsheet-like behaviors and tying the knot. It is defined as:
loeb :: Functor f => f (f a -> a) -> f a
loeb fs = xs
where xs = fmap ($ xs) fs