Created
November 13, 2014 00:58
-
-
Save localshred/958cbc26674bbb6d4079 to your computer and use it in GitHub Desktop.
erlang case statment pattern matching from http://learnyousomeerlang.com/syntax-in-functions#pattern-matching
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
beach(Temperature) -> | |
case Temperature of | |
{celsius, N} when N >= 20, N =< 45 -> | |
'favorable'; | |
{kelvin, N} when N >= 293, N =< 318 -> | |
'scientifically favorable'; | |
{fahrenheit, N} when N >= 68, N =< 113 -> | |
'favorable in the US'; | |
_ -> | |
'avoid beach' | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment