aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam/list.gleam20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam
index d53e95e..a01460c 100644
--- a/src/gleam/list.gleam
+++ b/src/gleam/list.gleam
@@ -582,6 +582,26 @@ pub fn new() -> List(a) {
[]
}
+/// Returns the given item wrapped in a list.
+///
+/// ## Examples
+///
+/// ```gleam
+/// wrap(1)
+/// // -> [1]
+///
+/// wrap(["a", "b", "c"])
+/// // -> [["a", "b", "c"]]
+///
+/// wrap([[]])
+/// // -> [[[]]]
+/// ```
+///
+///
+pub fn wrap(item: a) -> List(a) {
+ [item]
+}
+
/// Joins one list onto the end of another.
///
/// This function runs in linear time, and it traverses and copies the first