Skip to content

Commit

Permalink
add 数学-杂项
Browse files Browse the repository at this point in the history
  • Loading branch information
sunface committed Apr 6, 2022
1 parent 1aad3b5 commit 8d2716f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/custom.js → assets/custom1.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ var initAll = function () {
script.src = "https://giscus.app/client.js";
script.async = true;
script.crossOrigin = "anonymous";
script.setAttribute("data-repo", "sunface/rust-cookbook");
script.setAttribute("data-repo-id", "R_kgDOHH0skA=");
script.setAttribute("data-repo", "studyrs/rusty-book");
script.setAttribute("data-repo-id", "R_kgDOGmKA_Q");
script.setAttribute("data-category", "giscus");
script.setAttribute("data-category-id", "DIC_kwDOHH0skM4COa8c");
script.setAttribute("data-mapping", "specific");
Expand Down
2 changes: 1 addition & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ src = "src"
[output.html]
no-section-label = true
additional-css = ["theme/style1.css"]
additional-js = ["assets/custom.js", "assets/bigPicture.js"]
additional-js = ["assets/custom1.js", "assets/bigPicture.js"]
git-repository-url = "https://github.com/studyrs/rusty-book"
edit-url-template = "https://github.com/studyrs/rusty-book/edit/main/{path}"

Expand Down
4 changes: 4 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@
- [网络协议]()
- [TCP/IP](protocols/tcpip.md)

- [文本处理]()
- [正则表达式](text/regex.md)
- [字符串解析](text/string.md)

23 changes: 23 additions & 0 deletions src/algos/math/misc.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# 杂项

### 大整数 Big int
使用 [BitInt](https://docs.rs/num/0.2.0/num/struct.BigInt.html) 可以对超过 128bit 的整数进行计算。

```rust,editable
use num::bigint::{BigInt, ToBigInt};
fn factorial(x: i32) -> BigInt {
if let Some(mut factorial) = 1.to_bigint() {
for i in 1..=x {
factorial = factorial * i;
}
factorial
}
else {
panic!("Failed to calculate factorial!");
}
}
fn main() {
println!("{}! equals {}", 100, factorial(100));
}
```
1 change: 1 addition & 0 deletions src/text/regex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 正则表达式
1 change: 1 addition & 0 deletions src/text/string.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 字符串解析

0 comments on commit 8d2716f

Please sign in to comment.