Skip to content

Commit

Permalink
Revert "feat: add ci badge #11"
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunchen authored Mar 8, 2024
1 parent 3a01cf6 commit 33d5d97
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# 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 <https://mooncakes.io/docs/#/moonbitlang/core/>. This repository serves as the development repository.

## Current status

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).
68 changes: 34 additions & 34 deletions list/list.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// under the License.

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

/// Iterates over the list.
///
///
/// # Example
///
///
/// ```
/// from_array([1, 2, 3, 4, 5]).iter(print) // output: 12345
/// ```
Expand All @@ -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) {
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 All @@ -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])
Expand All @@ -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])
Expand All @@ -176,9 +176,9 @@ test "tail" {
}

/// Get first element of the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).head())
/// // output: 1
Expand All @@ -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)
Expand All @@ -220,9 +220,9 @@ test "head option" {
}

/// Last element of the list.
///
///
/// # Example
///
///
/// ```
/// debug(from_array([1, 2, 3, 4, 5]).last())
/// // output: 5
Expand All @@ -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])
Expand All @@ -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])
Expand All @@ -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])
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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] })
Expand Down Expand Up @@ -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])
/// ```
Expand All @@ -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"])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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] {
Expand Down
8 changes: 4 additions & 4 deletions ref/ref.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
/// ```
Expand Down

0 comments on commit 33d5d97

Please sign in to comment.