-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from niuez/v0.8
v0.8.0
- Loading branch information
Showing
48 changed files
with
1,812 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
[package] | ||
name = "niu" | ||
version = "0.6.1" | ||
version = "0.8.0" | ||
authors = ["niuez <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
nom = "6.0.0" | ||
nom = "7.0.0" | ||
log = "0.4.0" | ||
env_logger = "0.8.4" | ||
clap = "2.33.3" | ||
|
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,18 @@ | ||
import "std/opes.niu" | ||
import "std/u64.niu" | ||
|
||
struct Hoge {} {} | ||
|
||
impl Clone for Hoge { | ||
fn clone(self: &Self) -> Self { Hoge {} } | ||
} | ||
impl Copy for Hoge {} | ||
|
||
fn clone_t<T>(t: &T) -> T where T: Copy { | ||
*t | ||
} | ||
|
||
fn main() -> void { | ||
clone_t(&Hoge{}); | ||
clone_t(&1); | ||
} |
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,27 @@ | ||
import "math/matrix.niu" | ||
import "math/modint.niu" | ||
#include <iostream> | ||
|
||
impl Field for Modint<M9982> { | ||
fn zero() -> Self { Modint::init(0) } | ||
fn one() -> Self { Modint::init(1) } | ||
} | ||
|
||
fn scan<T>(t: &mut T) -> void $${std::cin >> $arg(t);}$$ | ||
fn println<T>(t: &T) -> void $${std::cout << $arg(t) << std::endl;}$$ | ||
|
||
fn main() -> void { | ||
let mut n = 0; | ||
scan(&mut n); | ||
|
||
let mut mat = Matrix<Modint<M9982>>::zero(2, 2); | ||
let mut ini = Matrix::zero(2, 1); | ||
mat[0][1] = Modint::init(1); | ||
mat[1][0] = Modint::init(1); | ||
mat[1][1] = Modint::init(1); | ||
ini[0][0] = Modint::init(0); | ||
ini[1][0] = Modint::init(1); | ||
|
||
let ans = &mat.pow(n) * &ini; | ||
println(&ans[0][0].a); | ||
} |
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 @@ | ||
import "std/vec.niu" | ||
import "std/u64.niu" | ||
#include <iostream> | ||
|
||
fn println(a: u64) -> void $${std::cout << $arg(a) << std::endl;}$$ | ||
|
||
fn main() -> void { | ||
let mut v = Vec::new(); | ||
for i = 0; i < 5; i = i + 1 { | ||
v.push(i); | ||
} | ||
for e in &v { | ||
println(*e); | ||
} | ||
for e in &mut v { | ||
*e = *e + 10; | ||
} | ||
for e in v { | ||
println(e); | ||
} | ||
} |
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,31 @@ | ||
import "std/map.niu" | ||
import "std/u64.niu" | ||
#include <iostream> | ||
|
||
fn println<T>(t: &T) -> void $${std::cout << $arg(t) << std::endl;}$$ | ||
|
||
fn main() -> void { | ||
let mut mp = Map::empty(); | ||
mp.insert(1, 1i64); | ||
mp.insert(5, 5i64); | ||
mp.insert(4, 4i64); | ||
mp.insert(2, 2i64); | ||
mp.insert(3, 3i64); | ||
|
||
for x in &mp { | ||
println(&x.0); | ||
println(&x.1); | ||
} | ||
|
||
for i = 1; i <= 5; i = i + 1 { | ||
println(&mp[&i]); | ||
} | ||
|
||
mp.remove(&3); | ||
|
||
for x in mp { | ||
let (k, v) = x; | ||
println(&k); | ||
println(&v); | ||
} | ||
} |
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,26 @@ | ||
import "std/u64.niu" | ||
|
||
struct Hoge { | ||
s: u64, | ||
t: u64, | ||
} { | ||
fn print(self: &Self) -> void {} | ||
fn move_hoge(self: Self) -> void {} | ||
} | ||
|
||
fn main() -> void { | ||
let mut hoge = Hoge { s: 9, t: 1 }; | ||
let b = hoge.s; | ||
let c = hoge.t; | ||
hoge.s = 91; | ||
hoge.t = 19; | ||
hoge.print(); | ||
let huga = hoge; | ||
huga.move_hoge(); | ||
|
||
let mut v = 100; | ||
for i = 0; i < 5; i = i + 1 { | ||
let w = v; | ||
v = 120; | ||
} | ||
} |
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 @@ | ||
import "std/set.niu" | ||
import "std/u64.niu" | ||
#include <iostream> | ||
|
||
fn println<T>(t: &T) -> void $${std::cout << $arg(t) << std::endl;}$$ | ||
|
||
fn main() -> void { | ||
let mut st = Set::empty(); | ||
st.insert(5); | ||
st.insert(2); | ||
st.insert(3); | ||
st.insert(1); | ||
st.insert(4); | ||
for x in &st { | ||
println(x); | ||
} | ||
st.remove(&3); | ||
for x in st { | ||
println(&x); | ||
} | ||
} |
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,28 @@ | ||
import "std/tuple.niu" | ||
import "std/u64.niu" | ||
|
||
struct Hoge { | ||
val: u64 | ||
} {} | ||
|
||
fn throw_tuple(xyz: (u64, i64, bool)) -> (u64, i64, bool) { | ||
xyz | ||
} | ||
|
||
fn main() -> void { | ||
let (x, y, z) = throw_tuple((91u64, 19i64, false, )); | ||
|
||
let (a, b, (c, d)) = (1, 2, (3, 4)); | ||
|
||
let t = (1, 2); | ||
let t0 = t.0; | ||
let t1 = t.1; | ||
|
||
let mut tt = (Hoge { val: 8 }, false); | ||
let tt0 = tt.0; | ||
tt.0 = tt0; | ||
|
||
let ttt = tt; | ||
|
||
let copy_t = t; | ||
} |
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 |
---|---|---|
|
@@ -43,8 +43,6 @@ struct UnionFind { | |
self.par[yr] = xr; | ||
} | ||
} | ||
else { | ||
} | ||
} | ||
} | ||
|
||
|
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
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
Oops, something went wrong.