aboutsummaryrefslogtreecommitdiff
path: root/gen/src/std@tuple.erl
diff options
context:
space:
mode:
Diffstat (limited to 'gen/src/std@tuple.erl')
-rw-r--r--gen/src/std@tuple.erl28
1 files changed, 28 insertions, 0 deletions
diff --git a/gen/src/std@tuple.erl b/gen/src/std@tuple.erl
new file mode 100644
index 0000000..0c9e89d
--- /dev/null
+++ b/gen/src/std@tuple.erl
@@ -0,0 +1,28 @@
+-module(std@tuple).
+-compile(no_auto_import).
+
+-export([new/2, first/1, second/1, swap/1, fetch/2]).
+
+new(A, B) ->
+ {A, B}.
+
+first(Tup) ->
+ {A, _} = Tup,
+ A.
+
+second(Tup) ->
+ {_, A} = Tup,
+ A.
+
+swap(Tup) ->
+ {A, B} = Tup,
+ {B, A}.
+
+fetch(Haystack, Needle) ->
+ std@list:find(Haystack, fun(Tuple) -> case first(Tuple) =:= Needle of
+ true ->
+ {ok, second(Tuple)};
+
+ false ->
+ {error, []}
+ end end).