aboutsummaryrefslogtreecommitdiff
path: root/learn-you-some-erlang/cards.erl
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2024-02-23 07:08:18 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2024-02-23 07:08:18 +0100
commit5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e (patch)
tree982ca2e7f9ac4e8c350dfb5c4f60bcfdfff5afaf /learn-you-some-erlang/cards.erl
parent05ae56e5e89abf2993f84e6d52b250131f247c35 (diff)
downloaderlang-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/cards.erl')
-rw-r--r--learn-you-some-erlang/cards.erl16
1 files changed, 16 insertions, 0 deletions
diff --git a/learn-you-some-erlang/cards.erl b/learn-you-some-erlang/cards.erl
new file mode 100644
index 0000000..ee8dcd2
--- /dev/null
+++ b/learn-you-some-erlang/cards.erl
@@ -0,0 +1,16 @@
+-module(cards).
+-export([kind/1, main/0]).
+
+-type suit() :: spades | clubs | hearts | diamonds.
+-type value() :: 1..10 | j | q | k.
+-type card() :: {suit(), value()}.
+
+-spec kind(card()) -> face | number.
+kind({_, A}) when A >= 1, A =< 10 -> number;
+kind(_) -> face.
+
+main() ->
+ number = kind({spades, 7}),
+ face = kind({hearts, k}),
+ number = kind({rubies, 4}),
+ face = kind({clubs, q}).