-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
///| | ||
///without spaces | ||
/// 返回一个新数组,其中元素被反转。 | ||
/// | ||
/// # 示例 | ||
/// | ||
/// ``` | ||
/// reverse([1,2,3,4]) |> println() | ||
/// ``` | ||
fn reverse[T](xs : Array[T]) -> Array[T] { | ||
Array::rev(xs) | ||
} | ||
|
||
test { | ||
assert_eq!(reverse([1,2,3,4]), [4, 3, 2, 1]) // pass | ||
assert_eq!(reverse([1,2,3,4]), [4, 3, 2, 1]) //pass | ||
let _ = "https://github.com" | ||
} | ||
|
||
fn main { | ||
let greeting = | ||
#| | ||
#| (\(\ | ||
#| ( -.-) | ||
#| o_(")(") | ||
#| __ __ ____ __ ___ ____ _ __ | ||
#| / / / /__ / / /___ / |/ /___ ____ ____ / __ )(_) /_ | ||
#| / /_/ / _ \/ / / __ \ / /|_/ / __ \/ __ \/ __ \/ __ / / __/ | ||
#| / __ / __/ / / /_/ / / / / / /_/ / /_/ / / / / /_/ / / /_ | ||
#| /_/ /_/\___/_/_/\____/ /_/ /_/\____/\____/_/ /_/_____/_/\__/ | ||
#| | ||
println(greeting) | ||
|
||
// Define two array of Int. | ||
let arr1 : Array[Int] = [1, 2, 3, 4, 5] | ||
|
||
// Let compiler infer the type. | ||
let arr2 = [6, 7, 8, 9, 10] | ||
|
||
// Get the length of the array. | ||
println(arr1.length()) | ||
|
||
// Access the element of the array. | ||
println(arr1[1]) | ||
|
||
// We change the elements inside the array. | ||
// The binding of arr1 is immutable, it still points to the same array. | ||
// The internal mutability of the array is defined by the standard library and | ||
// is not affected by the binding. | ||
arr1.push(6) | ||
arr1[1] = 10 | ||
println("push and change element:") | ||
println(arr1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package moonbitlang/core/array | ||
|
||
alias @moonbitlang/core/quickcheck as @quickcheck | ||
|
||
// Values | ||
|
||
// Types and methods | ||
impl FixedArray { | ||
all[T](Self[T], (T) -> Bool) -> Bool | ||
} | ||
|
||
// Type aliases | ||
|
||
// Traits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
# github.com/AlDanial/cloc | ||
header : | ||
cloc_url : github.com/AlDanial/cloc | ||
cloc_version : 2.02 | ||
elapsed_seconds : 0.0278570652008057 | ||
n_files : 2 | ||
n_lines : 27 | ||
files_per_second : 35.8975359676826 | ||
lines_per_second : 969.23347112743 | ||
report_file : ./tests/outputs/moonbit.yaml | ||
'MoonBit' : | ||
nFiles: 2 | ||
blank: 12 | ||
comment: 21 | ||
code: 35 | ||
SUM: | ||
blank: 12 | ||
comment: 21 | ||
code: 35 | ||
nFiles: 2 |