Skip to content

Commit 2274e48

Browse files
committed
fmt
1 parent b2de510 commit 2274e48

29 files changed

+434
-46
lines changed

algorithm/algo.mbt

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
///| Min Max
22
3-
///| Maximum value
3+
///|
4+
/// Maximum value
45
///
56
/// # Parameters
67
///
@@ -23,7 +24,8 @@ pub fn[T : Compare] max(a : T, b : T) -> T {
2324
}
2425
}
2526
26-
///| Minimum value
27+
///|
28+
/// Minimum value
2729
///
2830
/// # Parameters
2931
///
@@ -46,7 +48,8 @@ pub fn[T : Compare] min(a : T, b : T) -> T {
4648
}
4749
}
4850
49-
///| Maximum value in array
51+
///|
52+
/// Maximum value in array
5053
///
5154
/// # Parameters
5255
///
@@ -70,7 +73,8 @@ pub fn[T : Compare] max_element(data : Array[T]) -> T {
7073
data.fold(init=data[0], fn(mx, x) { if x > mx { x } else { mx } })
7174
}
7275
73-
///| Minimum value in array
76+
///|
77+
/// Minimum value in array
7478
///
7579
/// # Parameters
7680
///
@@ -96,7 +100,8 @@ pub fn[T : Compare] min_element(data : Array[T]) -> T {
96100
97101
///| Binary Search
98102
99-
///| Find first index of element in array that not less than value
103+
///|
104+
/// Find first index of element in array that not less than value
100105
///
101106
/// # Parameters
102107
///
@@ -130,7 +135,8 @@ pub fn[T : Compare] lower_bound(data : Array[T], value : T) -> Int {
130135
first
131136
}
132137
133-
///| Find first index of element in array that bigger than value
138+
///|
139+
/// Find first index of element in array that bigger than value
134140
///
135141
/// # Parameters
136142
///
@@ -163,7 +169,8 @@ pub fn[T : Compare] upper_bound(data : Array[T], value : T) -> Int {
163169
first
164170
}
165171
166-
///| Find whether a value in the array
172+
///|
173+
/// Find whether a value in the array
167174
///
168175
/// # Parameters
169176
///
@@ -185,7 +192,8 @@ pub fn[T : Compare] binary_search(data : Array[T], value : T) -> Bool {
185192
first != data.length() && data[first] == value
186193
}
187194
188-
///| Find range of array equal to value
195+
///|
196+
/// Find range of array equal to value
189197
///
190198
/// # Parameters
191199
///
@@ -213,7 +221,8 @@ pub fn[T : Compare] equal_range(data : Array[T], value : T) -> (Int, Int) {
213221
214222
///| Merge
215223
216-
///| Merge two sorted array in sequence
224+
///|
225+
/// Merge two sorted array in sequence
217226
///
218227
/// # Parameters
219228
///
@@ -254,7 +263,8 @@ pub fn[T : Compare] merge(data1 : Array[T], data2 : Array[T]) -> Array[T] {
254263
res.iter().concat(data2[j:].iter()).collect()
255264
}
256265
257-
///| Fast Exponentiation
266+
///|
267+
/// Fast Exponentiation
258268
///
259269
/// # Parameters
260270
///
@@ -290,7 +300,8 @@ pub(all) struct Point {
290300
y : Int
291301
} derive(Show)
292302
293-
///| Calculate max manhattan distance
303+
///|
304+
/// Calculate max manhattan distance
294305
///
295306
/// # Parameters
296307
///
@@ -401,7 +412,8 @@ pub fn ext_euc(a : Int, b : Int) -> (Int, Int, Int) {
401412
}
402413
}
403414
404-
///| Calculate Inverse Element
415+
///|
416+
/// Calculate Inverse Element
405417
///
406418
/// # Parameters
407419
///

algorithm/pkg.generated.mbti

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Generated using `moon info`, DON'T EDIT IT
2+
package "Lampese/Algorithms-Moonbit/algorithm"
3+
4+
// Values
5+
fn[T : Compare] binary_search(Array[T], T) -> Bool
6+
7+
fn[T : Compare] equal_range(Array[T], T) -> (Int, Int)
8+
9+
fn ext_euc(Int, Int) -> (Int, Int, Int)
10+
11+
fn gcd(Int, Int) -> Int
12+
13+
fn lcm(Int, Int) -> Int
14+
15+
fn[T : Compare] lower_bound(Array[T], T) -> Int
16+
17+
fn[T : Compare] max(T, T) -> T
18+
19+
fn[T : Compare] max_element(Array[T]) -> T
20+
21+
fn max_manhattan_distance(Array[Point]) -> Int
22+
23+
fn[T : Compare] merge(Array[T], Array[T]) -> Array[T]
24+
25+
fn[T : Compare] min(T, T) -> T
26+
27+
fn[T : Compare] min_element(Array[T]) -> T
28+
29+
fn mod_inverse(Int, Int) -> Int
30+
31+
fn quick_pow(Int, Int) -> Int64
32+
33+
fn[T : Compare] upper_bound(Array[T], T) -> Int
34+
35+
// Errors
36+
37+
// Types and methods
38+
pub(all) struct Point {
39+
x : Int
40+
y : Int
41+
}
42+
impl Show for Point
43+
44+
// Type aliases
45+
46+
// Traits
47+

apsp/floyd.mbt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ struct Floyd {
44
node : Int
55
}
66

7-
///| Create Floyd (All-Pairs Shortest Path)
7+
///|
8+
/// Create Floyd (All-Pairs Shortest Path)
89
///
910
/// # Parameters
1011
///
@@ -47,7 +48,8 @@ pub fn create_floyd(edge : Array[(Int, Int, Int)], node : Int) -> Floyd {
4748
Floyd::{ map, node }
4849
}
4950
50-
///| Query shortest path
51+
///|
52+
/// Query shortest path
5153
///
5254
/// # Parameters
5355
///

apsp/pkg.generated.mbti

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Generated using `moon info`, DON'T EDIT IT
2+
package "Lampese/Algorithms-Moonbit/apsp"
3+
4+
// Values
5+
fn create_floyd(Array[(Int, Int, Int)], Int) -> Floyd
6+
7+
// Errors
8+
9+
// Types and methods
10+
type Floyd
11+
fn Floyd::query(Self, Int, Int) -> Int
12+
13+
// Type aliases
14+
15+
// Traits
16+

avl/pkg.generated.mbti

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Generated using `moon info`, DON'T EDIT IT
2+
package "Lampese/Algorithms-Moonbit/avl"
3+
4+
// Values
5+
fn balance_factor(AVLTree) -> Int
6+
7+
fn height(AVLTree?) -> Int
8+
9+
fn insert(AVLTree?, Int) -> AVLTree?
10+
11+
fn left_rotate(AVLTree) -> AVLTree
12+
13+
fn max(Int, Int) -> Int
14+
15+
fn new(Int) -> AVLTree
16+
17+
fn remove(AVLTree?, Int) -> AVLTree?
18+
19+
fn right_rotate(AVLTree) -> AVLTree
20+
21+
fn rotate(AVLTree) -> AVLTree
22+
23+
fn update_height(AVLTree) -> AVLTree
24+
25+
// Errors
26+
27+
// Types and methods
28+
pub(all) struct AVLTree {
29+
val : Int
30+
height : Int
31+
left : AVLTree?
32+
right : AVLTree?
33+
}
34+
35+
// Type aliases
36+
37+
// Traits
38+

binary_indexed/binary_indexed_tree.mbt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ fn update_in(self : Tree[Int], x : Int, val : Int) -> Unit {
1818
}
1919
}
2020

21-
///| Update
21+
///|
22+
/// Update
2223
///
2324
/// # Parameters
2425
///
@@ -40,7 +41,8 @@ pub fn update(self : Tree[Int], left : Int, right : Int, val : Int) -> Unit {
4041
self.update_in(right + 1, -val)
4142
}
4243
43-
///| Build Binary Indexed Tree
44+
///|
45+
/// Build Binary Indexed Tree
4446
///
4547
/// # Parameters
4648
///
@@ -64,7 +66,8 @@ pub fn query(self : Tree[Int], x : Int) -> Int {
6466
res
6567
}
6668
67-
///| Build Binary Indexed Tree
69+
///|
70+
/// Build Binary Indexed Tree
6871
///
6972
/// # Parameters
7073
///

binary_indexed/pkg.generated.mbti

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Generated using `moon info`, DON'T EDIT IT
2+
package "Lampese/Algorithms-Moonbit/binary_indexed"
3+
4+
// Values
5+
fn bitTree(Array[Int]) -> Tree[Int]
6+
7+
// Errors
8+
9+
// Types and methods
10+
type Tree[Int]
11+
fn Tree::query(Self[Int], Int) -> Int
12+
fn Tree::update(Self[Int], Int, Int, Int) -> Unit
13+
14+
// Type aliases
15+
16+
// Traits
17+

combinator/Combinator.mbt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fn qpow(base : Int64, exp : Int64, mod : Int64) -> Int64 {
2222
res
2323
}
2424

25-
///| Constructor
25+
///|
26+
/// Constructor
2627
///
2728
/// # Parameters
2829
///
@@ -47,7 +48,8 @@ pub fn Comb::new(size : Int, mod : Int64) -> Comb {
4748
{ fact, inv_fact, mod }
4849
}
4950
50-
///| Combination
51+
///|
52+
/// Combination
5153
///
5254
/// # Parameters
5355
///
@@ -74,7 +76,8 @@ pub fn c(self : Comb, x : Int, y : Int) -> Int64 {
7476
self.fact[x] * self.inv_fact[y] % self.mod * self.inv_fact[x - y] % self.mod
7577
}
7678
77-
///| Arrangement
79+
///|
80+
/// Arrangement
7881
///
7982
/// # Parameters
8083
///

combinator/pkg.generated.mbti

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Generated using `moon info`, DON'T EDIT IT
2+
package "Lampese/Algorithms-Moonbit/combinator"
3+
4+
// Values
5+
6+
// Errors
7+
8+
// Types and methods
9+
type Comb
10+
fn Comb::a(Self, Int, Int) -> Int64
11+
fn Comb::c(Self, Int, Int) -> Int64
12+
fn Comb::new(Int, Int64) -> Self
13+
14+
// Type aliases
15+
16+
// Traits
17+

dsu/dsu.mbt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ struct DSU {
66

77
///|
88
9-
///| Construct a dsu structure
9+
///|
10+
/// Construct a dsu structure
1011
///
1112
/// # Parameters
1213
///
@@ -32,7 +33,8 @@ pub fn DSU::new(n : Int) -> DSU {
3233
{ parent, siz }
3334
}
3435
35-
///| Find the root of x
36+
///|
37+
/// Find the root of x
3638
///
3739
/// # Parameters
3840
///
@@ -59,7 +61,8 @@ pub fn find(self : DSU, x : Int) -> Int {
5961
root
6062
}
6163
62-
///| Merge two unions x and y into one unoin
64+
///|
65+
/// Merge two unions x and y into one unoin
6366
///
6467
/// # Parameters
6568
///
@@ -94,7 +97,8 @@ pub fn merge(self : DSU, x : Int, y : Int) -> Bool {
9497
true
9598
}
9699
97-
///| Find out that if x and y belong to the same union
100+
///|
101+
/// Find out that if x and y belong to the same union
98102
///
99103
/// # Parameters
100104
///
@@ -117,7 +121,8 @@ pub fn same(self : DSU, x : Int, y : Int) -> Bool {
117121
self.find(x) == self.find(y)
118122
}
119123
120-
///| Get the size of the union that x belongs to
124+
///|
125+
/// Get the size of the union that x belongs to
121126
///
122127
/// # Parameters
123128
///

0 commit comments

Comments
 (0)