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 forcedReveal doorWithPrize fstChoice = | |
| match (doorWithPrize + fstChoice) with | |
| |3 -> 3 | |
| |4 -> 2 | |
| |_ -> 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
| let forcedReveal doorWithPrize fstChoice = | |
| match doorWithPrize with | |
| |1 -> if fstChoice = 2 then 3 | |
| else 2 | |
| |2 -> if fstChoice = 1 then 3 | |
| else 1 | |
| |_ -> if fstChoice = 1 then 2 | |
| else 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
| let rndReveal doorWithPrize = | |
| let rnd = seedRnd.Next(1,3) | |
| match doorWithPrize with | |
| |1 -> (rnd + 1) | |
| |2 -> if rnd = 1 then 1 | |
| else 3 | |
| |_ -> rnd |
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
| type game(doorWithPrize: int, fstChoice: int, revealedDoor: int) = | |
| member x.winFstChoice = (doorWithPrize = fstChoice) | |
| member x.winSwitch = (not(doorWithPrize = fstChoice)&&(not(doorWithPrize = revealedDoor))) | |
| member x.revealed = revealedDoor | |
| member x.ToString = "Prize Door: " + doorWithPrize.ToString() + "; " | |
| + "First Choice: " + fstChoice.ToString() + "; " | |
| + "Revealed Door: " + revealedDoor.ToString() + "; " | |
| + "Wins 1st Choice: " + x.winFstChoice.ToString() + "; " | |
| + "Wins Switch: " + x.winSwitch.ToString() |
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 f = (fun acc -> ("b" :: (acc |> (fun acc -> ("c" :: (acc |> (fun acc -> ("a" :: (acc |> (fun acc -> acc)))) |> (fun acc -> acc) |> (fun x -> x)))|> (fun acc -> acc) ))) |> (fun acc -> acc) ) | |
| f [] |
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
| static member private foldHeapStep4 nodeF leafV (h : list<BinomialTree<'a>>) = | |
| let rec loop (h : list<BinomialTree<'a>>) cont = | |
| match h with | |
| | Node(_, a, [])::[] -> loop [] (fun lacc -> | |
| loop [] (fun racc -> | |
| cont (nodeF a lacc racc))) | |
| | Node(_, a, h')::[] -> loop h' (fun lacc -> | |
| loop [] (fun racc -> | |
| cont (nodeF a lacc racc))) |
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
| static member private foldHeap nodeF leafV (h : list<BinomialTree<'a>>) = | |
| let rec loop (h : list<BinomialTree<'a>>) cont = | |
| match h with | |
| | Node(_, a, h')::tl -> loop h' (fun lacc -> | |
| loop tl (fun racc -> | |
| cont (nodeF a lacc racc))) | |
| | _ -> cont leafV | |
| loop h (fun x -> x) |
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
| static member private foldHeapStep3 nodeF leafV (h : list<BinomialTree<'a>>) = | |
| let rec loop (h : list<BinomialTree<'a>>) cont = | |
| match h with | |
| | Node(_, a, [])::[] -> loop [] (fun lacc -> | |
| loop [] (fun racc -> | |
| cont (nodeF a lacc racc))) | |
| | Node(_, a, h')::[] -> loop h' (fun lacc -> | |
| loop [] (fun racc -> | |
| cont (nodeF a lacc racc))) |
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
| static member private foldHeapStep2 c1 c2 c3 (t : list<BinomialTree<'a>>) = | |
| let rec loop (h : list<BinomialTree<'a>>) cont = | |
| match t with | |
| | Node(_, a, [])::[] -> cont (c1 [a]) | |
| | Node(_, a, h')::[] -> loop h' (fun acc -> cont (c2 a acc)) | |
| | Node(_, a, [])::tl -> loop tl (fun acc -> cont (c2 a acc)) | |
| | Node(_, a, h')::tl -> loop h' (fun lacc -> | |
| loop tl (fun racc -> | |
| cont (c3 a lacc racc))) |
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
| static member private foldHeapStep1 (h : list<BinomialTree<'a>>) = | |
| let rec loop (h : list<BinomialTree<'a>>) cont = | |
| match h with | |
| | Node(_, a, [])::[] -> cont [a] | |
| | Node(_, a, h')::[] -> loop h' (fun acc -> cont (a :: acc)) | |
| | Node(_, a, [])::tl -> loop tl (fun acc -> cont (a :: acc)) | |
| | Node(_, a, h')::tl -> loop h' (fun lacc -> loop tl (fun racc -> cont (a :: racc @ lacc))) | |
| | _ -> failwith "can't get here" | |