aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Reusch <jreusch4@gmail.com>2024-08-11 15:07:16 +0200
committerLouis Pilfold <louis@lpil.uk>2024-08-13 19:15:00 +0200
commitc832d873f6c6d04d545b5679ea266ef1c46ef995 (patch)
tree5458e0b70d5924c2cee11799d794d62eb1374bb0
parentcc2fdd1a7b80749b7aef50fbbd1399ca3a3accaa (diff)
downloadgleam_stdlib-c832d873f6c6d04d545b5679ea266ef1c46ef995.tar.gz
gleam_stdlib-c832d873f6c6d04d545b5679ea266ef1c46ef995.zip
fix documentation examples
-rw-r--r--src/gleam/bool.gleam2
-rw-r--r--src/gleam/float.gleam2
-rw-r--r--src/gleam/int.gleam2
-rw-r--r--src/gleam/iterator.gleam2
-rw-r--r--src/gleam/list.gleam4
-rw-r--r--src/gleam/regex.gleam2
-rw-r--r--src/gleam/set.gleam10
7 files changed, 14 insertions, 10 deletions
diff --git a/src/gleam/bool.gleam b/src/gleam/bool.gleam
index ba2222b..e97d662 100644
--- a/src/gleam/bool.gleam
+++ b/src/gleam/bool.gleam
@@ -364,7 +364,7 @@ pub fn guard(
/// let name = ""
/// let greeting = fn() { "Hello, " <> name }
/// use <- lazy_guard(when: name == "", otherwise: greeting)
-/// let number = int.random(1, 99)
+/// let number = int.random(99)
/// let name = "User " <> int.to_string(number)
/// "Welcome, " <> name
/// // -> "Welcome, User 54"
diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam
index fed2fac..597f4ef 100644
--- a/src/gleam/float.gleam
+++ b/src/gleam/float.gleam
@@ -468,7 +468,7 @@ pub fn modulo(dividend: Float, by divisor: Float) -> Result(Float, Nil) {
///
/// ```gleam
/// divide(0.0, 1.0)
-/// // -> Ok(1.0)
+/// // -> Ok(0.0)
/// ```
///
/// ```gleam
diff --git a/src/gleam/int.gleam b/src/gleam/int.gleam
index f668a42..4318930 100644
--- a/src/gleam/int.gleam
+++ b/src/gleam/int.gleam
@@ -801,7 +801,7 @@ pub fn multiply(a: Int, b: Int) -> Int {
///
/// ```gleam
/// subtract(3, 1)
-/// // -> 2.0
+/// // -> 2
/// ```
///
/// ```gleam
diff --git a/src/gleam/iterator.gleam b/src/gleam/iterator.gleam
index 7762b46..f0fef0d 100644
--- a/src/gleam/iterator.gleam
+++ b/src/gleam/iterator.gleam
@@ -1440,7 +1440,7 @@ fn do_fold_until(
/// }
///
/// from_list([1, 2, 3, 4])
-/// |> fold_until(from: acc, with: f)
+/// |> fold_until(from: 0, with: f)
/// // -> 6
/// ```
///
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam
index 62cb1fc..b8f2369 100644
--- a/src/gleam/list.gleam
+++ b/src/gleam/list.gleam
@@ -861,7 +861,7 @@ pub type ContinueOrStop(a) {
/// False -> Stop(acc)
/// }
/// })
-/// // -> 6
+/// // -> 3
/// ```
///
pub fn fold_until(
@@ -1807,7 +1807,7 @@ pub fn each(list: List(a), f: fn(a) -> b) -> Nil {
///
/// ## Examples
///
-/// ```gleam
+/// ```
/// try_each(
/// over: [1, 2, 3],
/// with: function_that_might_fail,
diff --git a/src/gleam/regex.gleam b/src/gleam/regex.gleam
index 2c5e16b..d1f8ef0 100644
--- a/src/gleam/regex.gleam
+++ b/src/gleam/regex.gleam
@@ -206,7 +206,7 @@ fn do_scan(a: Regex, b: String) -> List(Match)
/// let assert Ok(re) = regex.from_string("[, +-]")
/// replace(each: re, in: "a,b-c d+e", with: "/")
/// // -> "a/b/c/d/e"
-/// `
+/// ```
@external(erlang, "gleam_stdlib", "regex_replace")
@external(javascript, "../gleam_stdlib.mjs", "regex_replace")
pub fn replace(
diff --git a/src/gleam/set.gleam b/src/gleam/set.gleam
index 38a77fb..5dfc749 100644
--- a/src/gleam/set.gleam
+++ b/src/gleam/set.gleam
@@ -224,7 +224,9 @@ pub fn filter(
/// ## Examples
///
/// ```gleam
-/// map(from_list([1, 2, 3, 4], fn(x) { x * 2 }))
+/// from_list([1, 2, 3, 4])
+/// |> map(with: fn(x) { x * 2 })
+/// |> to_list
/// // -> [2, 4, 6, 8]
/// ```
pub fn map(set: Set(member), with fun: fn(member) -> mapped) -> Set(mapped) {
@@ -239,7 +241,9 @@ pub fn map(set: Set(member), with fun: fn(member) -> mapped) -> Set(mapped) {
/// ## Examples
///
/// ```gleam
-/// drop(from_list([1, 2, 3, 4]), [1, 3])
+/// from_list([1, 2, 3, 4])
+/// |> drop([1, 3])
+/// |> to_list
/// // -> [2, 4]
/// ```
pub fn drop(from set: Set(member), drop disallowed: List(member)) -> Set(member) {
@@ -346,7 +350,7 @@ pub fn is_subset(first: Set(member), of second: Set(member)) -> Bool {
/// ## Examples
///
/// ```gleam
-/// is_disjoint(from_list([1, 2, 3], from_list([4, 5, 6])))
+/// is_disjoint(from_list([1, 2, 3]), from_list([4, 5, 6]))
/// // -> True
/// ```
///