Created
November 24, 2019 15:52
-
-
Save fotonmoton/f598b0d36e59a7c7bf27438d4f37f21f to your computer and use it in GitHub Desktop.
Raindrops
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
module Raindrops | |
let convert number = | |
let getSound (divider, sound) = | |
if (number % divider = 0) | |
then sound | |
else "" | |
let getSoundString drops = | |
drops | |
|> List.map getSound | |
|> List.fold (+) "" | |
let sound = getSoundString [(3, "Pling"); (5, "Plang"); (7, "Plong")] | |
if (sound = "") | |
then sprintf "%d" number | |
else sound |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment