This file contains hidden or 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
let list_sum ls = List.fold_left (fun a x->a+.x) 0.0 ls | |
let list_init c f = Array.to_list (Array.init c (fun x->f x)) | |
let normal zz = | |
match zz with | |
|v when v = 0.0 -> 0.5 | |
|v when v >= 6.0 -> 1.0 | |
|v when v <= -6.0 -> 0.0 | |
|v -> | |
let p = 0.2316419 in |
This file contains hidden or 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
let normal zz = | |
let p = 0.2316419 | |
let b = [0.31938153;-0.356563782;1.781477937;-1.821255978;1.330274428] | |
let f = 1.0/(sqrt (2.0*3.1415926)) | |
let abszz = abs zz | |
let ff = f*(exp((-(abszz**2.0)/2.0))) | |
let sfunc e b = b/((1.0+p*abszz)**e) | |
let sfunclist = List.init 6 (fun x->(sfunc (float x))) | |
let s = List.init 5 (fun x->List.nth sfunclist (x+1) (List.nth b x)) | |
let sz = ff * (List.sum s) |
This file contains hidden or 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 httplib, os, urllib, base64, datetime | |
folder = <<workfolder>> | |
url = "posterous.com" | |
user = <<userid>> | |
def file_contents(filename): | |
readfile = open(folder + "\\" + filename, 'r') | |
date = readfile.readline().strip('\n') | |
content = readfile.read() |
This file contains hidden or 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
#light | |
open System | |
let conc ls :string = | |
if List.length ls = 0 then "" | |
else List.reduce (fun x y -> x + y) ls | |
let av_chars = ["0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; "A"; "B"; "C"; "D"; "E"; "F"; "G"; "H"; "I"; "J"; "K"; "L"; "M"; "N"; "O"; "P"; "Q"; "R"; "S"; "T"; "U"; "V"; "W"; "X"; "Y"; "Z"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "k"; "l"; "m"; "n"; "o"; "p"; "q"; "r"; "s"; "t"; "u"; "v"; "w"; "x"; "y"; "z";] | |
let special_chars = ["!"; "#"; "$"; "%"; "&"; "*"; "+"; "-"; "_"; "?"; "@";] |
This file contains hidden or 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
(define black-scholes | |
[letrec ( | |
[normal (lambda (zz) | |
(if (= zz 0) 0.5 | |
[let ((p 0.2316419) (b1 0.31938153) (b2 -0.356563782) (b3 1.781477937) | |
(b4 -1.821255978) (b5 1.330274428) | |
(f (/ 1 (sqrt (* 2 3.1415926)))) | |
(abszz (abs zz))) | |
[let ((ff (* f (exp (/ (- (expt abszz 2)) 2)))) | |
(s1 (/ b1 (+ 1 (* p abszz)))) |
This file contains hidden or 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
Copyright (C) 2011, Eric Christensen | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all |
This file contains hidden or 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
(define even? | |
(lambda (x) | |
(cond ((= x 0) #t) | |
(else (odd? (- x 1)))))) | |
(define odd? | |
(lambda (x) | |
(cond ((= x 0) #f) | |
(else (even? (- x 1)))))) |
This file contains hidden or 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
(define (p) (p)) | |
(define (test x y) | |
(if (= x 0) | |
0 | |
y)) |
This file contains hidden or 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
(define (+ a b) | |
(if (= a 0) | |
b | |
(inc (+ (dec a) b)))) | |
(define (+ a b) | |
(if (= a 0) | |
b | |
(+ (dec a) (inc b)))) |
This file contains hidden or 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
(define pascal | |
(lambda (x) | |
(letrec ([last | |
(lambda (x) | |
(if (null? (cdr x)) x (last (cdr x))))] | |
[sum-two | |
(lambda (x) | |
(+ (car x) (cadr x)))] | |
[sum-doubles | |
(lambda (x) |