blob: 41902db3a6325f000043ad70b00b238ac5f7d761 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import list
pub fn new(a, b) {
{a, b}
}
pub fn first(tup) {
let {a, _} = tup
a
}
pub fn second(tup) {
let {_, a} = tup
a
}
pub fn swap(tup) {
let {a, b} = tup
{b, a}
}
pub fn fetch(haystack, needle) {
list:find(haystack, fn(tuple) {
case first(tuple) == needle {
| True -> tuple |> second |> Ok
| False -> Error([])
}
})
}
|