aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiacomo Cavalieri <giacomo.cavalieri@icloud.com>2023-05-31 23:21:06 +0200
committerLouis Pilfold <louis@lpil.uk>2023-06-01 18:10:44 +0100
commita177c9f9a61cca39e63b8b809d1b866004bfce2a (patch)
tree404f50d368d2e4cbb340870f8ae2572c62706d2c /src
parentf9539cc343249be45915c9f5b8778fbcdd6c0750 (diff)
downloadgleam_stdlib-a177c9f9a61cca39e63b8b809d1b866004bfce2a.tar.gz
gleam_stdlib-a177c9f9a61cca39e63b8b809d1b866004bfce2a.zip
Add `pair.new`
Diffstat (limited to 'src')
-rw-r--r--src/gleam/pair.gleam14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gleam/pair.gleam b/src/gleam/pair.gleam
index e9b99fd..894e6a8 100644
--- a/src/gleam/pair.gleam
+++ b/src/gleam/pair.gleam
@@ -69,3 +69,17 @@ pub fn map_second(of pair: #(a, b), with fun: fn(b) -> c) -> #(a, c) {
let #(a, b) = pair
#(a, fun(b))
}
+
+/// Returns a new pair with the given elements. This can also be done using the dedicated
+/// syntax instead: `new(1, 2) == #(1, 2)`.
+///
+/// ## Examples
+///
+/// ```gleam
+/// > new(1, 2)
+/// #(1, 2)
+/// ```
+///
+pub fn new(first: a, second: b) -> #(a, b) {
+ #(first, second)
+}