diff --git a/README.md b/README.md index 77925cc71..841136759 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # moonbitlang/core -[![check](https://github.com/moonbitlang/core/actions/workflows/check.yml/badge.svg)](https://github.com/moonbitlang/core/actions/workflows/check.yml) - moonbitlang/core is the standard library of the [MoonBit language](moonbitlang.com). It is released alongside the compiler. You can view the documentation for the latest official release at . This repository serves as the development repository. ## Current status @@ -9,7 +7,6 @@ moonbitlang/core is the standard library of the [MoonBit language](moonbitlang.c It is experimental and under active development. The API is subject to change. ## Contributing - -We are actively developing moonbitlang/core and appreciate your help! +We are actively developing moonbitlang/core and appreciate your help! To contribute, please read the contribution guidelines at [CONTRIBUTING.md](./CONTRIBUTING.md). \ No newline at end of file diff --git a/list/list.mbt b/list/list.mbt index 95846e024..0783ccf80 100644 --- a/list/list.mbt +++ b/list/list.mbt @@ -16,7 +16,7 @@ // under the License. /// Convert array to list. -/// +/// /// # Example /// /// ``` @@ -50,9 +50,9 @@ test "length" { } /// Iterates over the list. -/// +/// /// # Example -/// +/// /// ``` /// from_array([1, 2, 3, 4, 5]).iter(print) // output: 12345 /// ``` @@ -75,11 +75,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) { @@ -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]) @@ -129,9 +129,9 @@ pub fn to_array[T : Default](self : List[T]) -> Array[T] { } /// Filter the list. -/// +/// /// # Example -/// +/// /// ``` /// debug(from_array([1, 2, 3, 4, 5]).filter(fn(x){ x % 2 == 0})) /// // output: from_array([2, 4]) @@ -155,9 +155,9 @@ test "filter" { } /// Tail of the list. -/// +/// /// # Example -/// +/// /// ``` /// debug(from_array([1, 2, 3, 4, 5]).tail()) /// // output: from_array([2, 3, 4, 5]) @@ -176,9 +176,9 @@ test "tail" { } /// Get first element of the list. -/// +/// /// # Example -/// +/// /// ``` /// debug(from_array([1, 2, 3, 4, 5]).head()) /// // output: 1 @@ -196,9 +196,9 @@ test "head" { } /// Get first element of the list. -/// +/// /// # Example -/// +/// /// ``` /// debug(from_array([1, 2, 3, 4, 5]).head()) /// // output: Some(1) @@ -220,9 +220,9 @@ test "head option" { } /// Last element of the list. -/// +/// /// # Example -/// +/// /// ``` /// debug(from_array([1, 2, 3, 4, 5]).last()) /// // output: 5 @@ -241,9 +241,9 @@ test "last" { } /// Init of the list. -/// +/// /// # Example -/// +/// /// ``` /// debug(from_array([1, 2, 3, 4, 5]).init_()) /// // output: from_array([1, 2, 3, 4]) @@ -265,7 +265,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]) @@ -285,9 +285,9 @@ test "concat" { } /// Reverse the list. -/// +/// /// # Example -/// +/// /// ``` /// debug(from_array([1, 2, 3, 4, 5]).reverse()) /// // output: from_array([5, 4, 3, 2, 1]) @@ -307,7 +307,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 @@ -327,12 +327,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. @@ -350,7 +350,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] }) @@ -389,7 +389,7 @@ test "nth" { /// Create a list of length n with the given value /// /// # Example -/// +/// /// ``` /// debug(repeat(5, 1)) // output: from_array([1, 1, 1, 1, 1]) /// ``` @@ -407,9 +407,9 @@ test "repeat" { } /// Insert separator to the list. -/// +/// /// # Example -/// +/// /// ``` /// let ls = from_array(["1", "2", "3", "4", "5"]).separate_by("|") /// debug(ls) // output: from_array(["1", "|", "2", "|", "3", "|", "4", "|", "5"]) @@ -469,9 +469,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]) @@ -536,7 +536,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]) @@ -588,7 +588,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, f : (State) -> Option[(T, State)]) -> List[T] { diff --git a/ref/ref.mbt b/ref/ref.mbt index dbbd65011..7dba54c53 100644 --- a/ref/ref.mbt +++ b/ref/ref.mbt @@ -39,7 +39,7 @@ test "map" { } -/// This function allows you to temporarily replace the value of a reference with a new value, +/// This function allows you to temporarily replace the value of a reference with a new value, /// execute a given function, and then restore the original value of the reference. /// /// # Arguments @@ -51,15 +51,15 @@ test "map" { /// # Returns /// /// The result of executing the provided function `f`. -/// +/// /// # Example -/// +/// /// ``` /// let x = ref(1) /// x.protect(2, fn(){ /// debug(x) //output: ref(2) /// x.val = 3 -/// debug(x) //output: ref(3) +/// debug(x) //output: ref(3) /// }) /// debug(x) //output: ref(1) /// ```