diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-23 07:08:18 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-23 07:08:18 +0100 |
commit | 5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e (patch) | |
tree | 982ca2e7f9ac4e8c350dfb5c4f60bcfdfff5afaf /learn-you-some-erlang/cases.erl | |
parent | 05ae56e5e89abf2993f84e6d52b250131f247c35 (diff) | |
download | erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.gz erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.bz2 erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.xz erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.zip |
wip
Diffstat (limited to 'learn-you-some-erlang/cases.erl')
-rw-r--r-- | learn-you-some-erlang/cases.erl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/learn-you-some-erlang/cases.erl b/learn-you-some-erlang/cases.erl new file mode 100644 index 0000000..9b4f931 --- /dev/null +++ b/learn-you-some-erlang/cases.erl @@ -0,0 +1,22 @@ +-module(cases). +-export([insert/2,beach/1]). + +insert(X,[]) -> + [X]; +insert(X,Set) -> + case lists:member(X,Set) of + true -> Set; + false -> [X|Set] + end. + +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. |