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
private static T ID<T>(T x) => x; |
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
module BinarySearchTree | |
// Recursive tree type. | |
// Generic constraint to prevent creation of | |
// a tree where it doesn't make sense. | |
type Tree<'a when 'a : comparison> = | |
| Node of 'a * Tree<'a> * Tree<'a> | |
| Empty | |
/// Create an empty tree. |
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
// Get the factorial of an integer. | |
let factorial n = | |
// Actual recursive factorial implementation. | |
let rec f n = | |
match n with | |
| 0 -> 1 | |
| _ -> n * f (n - 1) | |
// Validate that n isn't negative | |
match n with |
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
Main<> | |
count = Read<> | |
n = 1 | |
loop n <= count | |
FizzBuzzNumber<n> | |
n => n + 1 | |
end | |
end |