Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
The wonders of F#
//F# Compiler for F# 4.0 (Open Source Edition), Mono 4.2.1 open System //Statically-typed unions //| -> "or", * -> "and" type Payment = | Cash | Check of int | Card of string * int * DateTime //Pattern matching //Signature: int -> Payment -> unit ("No" return value) let payWith amt payment = match payment with | Cash -> printfn "Cash owed: $%i" amt | Check c -> printfn "Check %i owed: $%i" c amt | Card (s, i, d) -> printfn "Card %s %i %s owed: $%i" s i (string d) amt payWith 100 Cash payWith 150 (Check 1234) Card ("abcdef-123456", 101, DateTime.Now) |> payWith 100 //Partial application let payStandardAmt = payWith 25 payStandardAmt Cash Cash |> payStandardAmt
run
|
edit
|
history
|
help
0
FizzBuzz without Modulo in F#
test private keyword
Sending an email
Musical Note Frequencies (Equal temperament)
KR#2
Calculate distance between two GPS latitude-longitude points.
Highly Modular FizzBuzz
F#: Basic Immutability vs. Mutability
Yet another Fibonacci
Split list without mutable values