Skip to content

Instantly share code, notes, and snippets.

@Shibe
Created July 12, 2017 11:33
Show Gist options
  • Save Shibe/541752e43790e2a2d0859d361b43559c to your computer and use it in GitHub Desktop.
Save Shibe/541752e43790e2a2d0859d361b43559c to your computer and use it in GitHub Desktop.
//ex1
let exercise1 (one : int) (two : int) (three : int) : int=
if one > two && one > three then
one
else if two > one && two > three then
two
else
three
// ex2
let exercise2 (option : Option<Option<'a>>) : Option<'a> =
match option with
| Some(x) -> x
| None -> None
//ex3
let rec exercise3 (ls : List<Option<'a>>) : List<'a> =
match ls with
| [] -> []
| h::t -> match h with
| None -> exercise3 t
| Some(a) -> a :: exercise3 t
//ex4
let exercise4 (funct : ('a * 'b) -> 'c) : ('a -> 'b -> 'c) =
(fun a b -> funct (a, b))
// ex5
type Person = {
name : string;
surname: string;
age:int;
}
let agePerson (person: Person) : Person = {person with age = person.age+1}
let fidgerspinner : Person = {name = "fidget"; surname = "spinner"; age = 69}
[<EntryPoint>]
let main argv =
printfn "%A" (agePerson fidgerspinner)
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment