Skip to content

Instantly share code, notes, and snippets.

View Tom01098's full-sized avatar
🦀

Tom Humphreys Tom01098

🦀
View GitHub Profile
@Tom01098
Tom01098 / FizzBuzz.jelly
Created March 23, 2019 13:48
FizzBuzz in Jelly
Main<>
count = Read<>
n = 1
loop n <= count
FizzBuzzNumber<n>
n => n + 1
end
end
@Tom01098
Tom01098 / factorial.fs
Created April 27, 2019 15:12
Factorial implemented in F#
// 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
@Tom01098
Tom01098 / BinarySearchTree.fs
Created April 30, 2019 11:55
A simple Binary Search Tree in F#.
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.
@Tom01098
Tom01098 / Identity.cs
Created September 5, 2019 12:01
An identity method that is more concise and readable than `x => x`.
private static T ID<T>(T x) => x;