Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Mar 17, 2024
1 parent 3786bc2 commit b936bf9
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions list/list.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

/// Convert array to list.
///
///
/// # Example
///
/// ```
Expand Down Expand Up @@ -49,9 +49,9 @@ test "length" {
}

/// Iterates over the list.
///
///
/// # Example
///
///
/// ```
/// from_array([1, 2, 3, 4, 5]).iter(print) // output: 12345
/// ```
Expand All @@ -74,11 +74,11 @@ test "iter" {
}

/// Iterates over the list with index.
///
///
/// # Example
///
///
/// ```
/// from_array([1, 2, 3, 4, 5]).iteri(fn(i, x) { print("(\(i),\(x)) ") })
/// from_array([1, 2, 3, 4, 5]).iteri(fn(i, x) { print("(\(i),\(x)) ") })
/// // output: (0,1) (1,2) (2,3) (3,4) (4,5)
/// ```
pub fn iteri[T](self : List[T], f : (Int, T) -> Unit) -> Unit {
Expand All @@ -101,9 +101,9 @@ test "iteri" {
}

/// Maps the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).map(fn(x){ x * 2}))
/// // output: from_array([2, 4, 6, 8, 10])
Expand Down Expand Up @@ -153,9 +153,9 @@ test "to array" {
}

/// Filter the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).filter(fn(x){ x % 2 == 0}))
/// // output: from_array([2, 4])
Expand Down Expand Up @@ -207,9 +207,9 @@ test "any" {
}

/// Tail of the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).tail())
/// // output: from_array([2, 3, 4, 5])
Expand All @@ -228,9 +228,9 @@ test "tail" {
}

/// Get first element of the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).head())
/// // output: 1
Expand All @@ -248,9 +248,9 @@ test "head" {
}

/// Get first element of the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).head())
/// // output: Some(1)
Expand All @@ -272,9 +272,9 @@ test "head option" {
}

/// Last element of the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).last())
/// // output: 5
Expand All @@ -293,9 +293,9 @@ test "last" {
}

/// Init of the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).init_())
/// // output: from_array([1, 2, 3, 4])
Expand All @@ -317,7 +317,7 @@ test "init_" {
/// Concatenate two lists.
///
/// # Example
///
///
/// ```
/// let ls = from_array([1, 2, 3, 4, 5]).concat(from_array([6, 7, 8, 9, 10]))
/// debug(ls) // output: from_array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
Expand All @@ -337,9 +337,9 @@ test "concat" {
}

/// Reverse the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).reverse())
/// // output: from_array([5, 4, 3, 2, 1])
Expand All @@ -359,7 +359,7 @@ test "reverse" {
/// Fold the list.
///
/// # Example
///
///
/// ```
/// let r = from_array([1, 2, 3, 4, 5]).fold(0, fn(acc, x) { acc + x })
/// debug(r) // output: 15
Expand All @@ -379,12 +379,12 @@ test "fold" {
/// Zip two lists.
///
/// # Example
///
///
/// ```
/// let r = zip(from_array([1, 2, 3, 4, 5]), from_array([6, 7, 8, 9, 10]))
/// debug(r) // output: from_array([(1, 6), (2, 7), (3, 8), (4, 9), (5, 10)]
/// ```
///
///
/// # Panics
///
/// If the two lists have different lengths, the function will panic.
Expand All @@ -402,7 +402,7 @@ pub fn zip[T, U](self : List[T], other : List[U]) -> List[(T, U)] {
/// `concat_map(f, ls)` equal to `ls.map(f).fold(Nil, fn(acc, x) { acc.concat(x) })))`
///
/// # Example
///
///
/// ```
/// let ls = from_array([1, 2, 3])
/// let r = ls.concat_map(fn(x) { [x, x * 2] })
Expand Down Expand Up @@ -464,7 +464,7 @@ test "nth_option" {
/// Create a list of length n with the given value
///
/// # Example
///
///
/// ```
/// debug(repeat(5, 1)) // output: from_array([1, 1, 1, 1, 1])
/// ```
Expand All @@ -482,9 +482,9 @@ test "repeat" {
}

/// Insert separator to the list.
///
///
/// # Example
///
///
/// ```
/// let ls = from_array(["1", "2", "3", "4", "5"]).intersperse("|")
/// debug(ls) // output: from_array(["1", "|", "2", "|", "3", "|", "4", "|", "5"])
Expand Down Expand Up @@ -547,9 +547,9 @@ test "unzip" {
}

/// flatten a list of lists.
///
///
/// # Example
///
///
/// ```
/// let ls = flatten(from_array([from_array([1,2,3]), from_array([4,5,6]), from_array([7,8,9])]))
/// debug(ls) // output: from_array([1, 2, 3, 4, 5, 6, 7, 8, 9])
Expand Down Expand Up @@ -614,7 +614,7 @@ test "minimum" {
/// Sort the list in ascending order.
///
/// # Example
///
///
/// ```
/// let ls = sort(from_array([1,123,52,3,6,0,-6,-76]))
/// debug(ls) // output: from_array([-76, -6, 0, 1, 3, 6, 52, 123])
Expand Down Expand Up @@ -666,7 +666,7 @@ test "contain" {
///
/// ```
/// // from_array([0, 1, 2])
/// unfold(0, fn { i => if i == 3 { None } else { Some(i, i + 1) } }) |> debug
/// unfold(0, fn { i => if i == 3 { None } else { Some(i, i + 1) } }) |> debug
/// ```
pub fn unfold[T, State](
init : State,
Expand Down

0 comments on commit b936bf9

Please sign in to comment.