-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alice
committed
Sep 11, 2018
1 parent
afc9e6b
commit 55acf49
Showing
5 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let rec sigma(a,b,f) = | ||
if a>b-1 then 0 | ||
else f(b) + sigma(a,b-1,f) | ||
|
||
(*let _ = print_int(sigma(3,2,fun x->x+2))*) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
let sumprod(f,n,k) = | ||
let x = ref 0.0 in | ||
let y = ref 1.0 in | ||
for i=1 to n do | ||
for j=1 to k do | ||
y := !y *. f(i,j) | ||
done; | ||
x := !x +. !y; | ||
y := 1.0 | ||
done; | ||
!x | ||
|
||
(*Hello World*) | ||
(* | ||
let rec mult(b,f) = | ||
if b<=0 then 1.0 | ||
else f(b) *. mult(b-1,f) | ||
let rec sigma(a,f) = | ||
if a<=0 then 0.0 | ||
else f(a) +. sigma(a-1,f) | ||
*) | ||
|
||
(*let rec sumprod(M,n,k) = | ||
let x = ref 0.0 in | ||
let y = ref 0.0 in | ||
let kk = ref k in | ||
match (n,k) with | ||
| (0,0) -> !x | ||
| (0,k') -> !x | ||
| (n',0) -> x := !x + !y; y := 0.0; sumprod(M,n'-1,!kk) | ||
| (n',k') -> y := !y * M(n',k') ;sumprod(M,n',k'-1) | ||
let em(a,b) = (float_of_int a)/.(float_of_int b) | ||
*) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
type team = Korea | France | Usa | Brazil | Japan | Nigeria | Cameroon | ||
| Poland | Portugal | Italy | Germany | Norway | Sweden | England | ||
| Argentina | ||
|
||
type tourna = LEAF of team | ||
| NODE of tourna * tourna | ||
|
||
let rec parenize tr = | ||
match tr with | ||
| NODE tr' -> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
t = ZERO | SUCC of nat | ||
type nat = ZERO | SUCC of nat | ||
|
||
let rec natadd (a,b) = | ||
match(a,b) with | ||
|