The standard no-arbitrage price
and the price time
(* Define monadic operations for a list *) | |
let return x = [x] | |
let (>>=) lst f = List.concat (List.map f lst) | |
(* Generate the combinations of k distinct objects from a list *) | |
(* Simple version |
<h1 id="fx-forwards">FX Forwards</h1> | |
<p>The standard no-arbitrage price <span class="MathJax_Preview"></span><span class="MathJax" id="MathJax-Element-1-Frame" role="textbox" aria-readonly="true"><nobr><span class="math" id="MathJax-Span-1" style="width: 2.069em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.715em; height: 0px; font-size: 121%;"><span style="position: absolute; clip: rect(1.243em 1000.003em 2.6em -0.469em); top: -2.122em; left: 0.003em;"><span class="mrow" id="MathJax-Span-2"><span class="msubsup" id="MathJax-Span-3"><span style="display: inline-block; position: relative; width: 1.656em; height: 0px;"><span style="position: absolute; clip: rect(1.243em 1000.003em 2.305em -0.469em); top: -2.122em; left: 0.003em;"><span class="mi" id="MathJax-Span-4" style="font-family: MathJax_Math; font-style: italic;">F<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.121em;"></span></span><span style="display: inline-block; width: 0px; h |
import Data.Map (Map, (!), insert, empty) | |
import Control.Monad.State (StateT, put, get, liftIO, evalStateT) | |
type Val = Int | |
type Var = String | |
data Instruction = | |
Set Val Var | |
| Print Var | |
| Add Var Var Var |
select [] = [] | |
select (x:xs) = (x,xs) : select xs | |
pairs nums = [(a, b) | (a, bs) <- select nums, b <- bs] | |
triples nums = [(a,b,c) | (a,bs) <- select nums, (b,cs) <- select bs, c <- cs] | |
overlap (a,b,c) (d,e,f) = | |
case compare a d of |
{-# LANGUAGE GADTs #-} | |
module Spreadsheet where | |
import Control.Applicative | |
import Control.Monad (forM_) | |
import Data.IORef | |
import Data.List (union) | |
import Data.Unique |
function b = isdual(a) | |
%ISDUAL Return true if a is of class Dual, else return false | |
b = strcmp(class(a),'Dual'); | |
end |
function SetDefault(argname,value) | |
%SETDEFAULT Provide a default value of VALUE for the argument ARGNAME. | |
% | |
%USAGE | |
% SetDefault('x',1) | |
% If no variable 'x' exists in the calling function, or if the variable exists | |
% but it is empty, then this call assigns the value 1 to 'x'. If the variable | |
% 'x' already exists, and is non-empty, then no action is taken. | |
% |
import Control.Monad.ST | |
import Data.STRef | |
-- Primitive actions | |
getSignal wire = wire GetSignal | |
setSignal wire x = wire (SetSignal x) | |
addAction wire proc = wire (AddAction proc) |
import random | |
import time | |
N = 200 | |
binsize = 8000; | |
xs = [100 * random.randint(1,40) for i in range(N)] | |
print '\nObjects to be packed:\n' | |
print xs |