diff options
author | QAEZZ <russian.devv@gmail.com> | 2023-02-04 01:00:50 -0600 |
---|---|---|
committer | QAEZZ <russian.devv@gmail.com> | 2023-02-04 01:00:50 -0600 |
commit | 2db9b9b61b27332906b1e72a82640d15918e7b0a (patch) | |
tree | 801f4f751dc30412ee2e88c186ed918eab278144 | |
parent | 5598b616dc33fea9a393e65878039b30daf801eb (diff) |
added `rust.rs` and `crystal.cr`
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | src/crystal.cr | 2 | ||||
-rw-r--r-- | src/rust.rs | 11 |
3 files changed, 17 insertions, 1 deletions
@@ -21,6 +21,8 @@ just godspeak in a variety of languages. [Scala]: https://github.com/The-Holy-Church-of-Terry-Davis/godspeak-bible/blob/main/src/scala.scala [R]: https://github.com/The-Holy-Church-of-Terry-Davis/godspeak-bible/blob/main/src/r.r [Swift]: https://github.com/The-Holy-Church-of-Terry-Davis/godspeak-bible/blob/main/src/swift.swift +[Rust]: https://github.com/The-Holy-Church-of-Terry-Davis/godspeak-bible/blob/main/src/rust.rs +[Crystal]: https://github.com/The-Holy-Church-of-Terry-Davis/godspeak-bible/blob/main/src/crystal.cr **Languages currently done:** | Language | Extension | Language | Extension | @@ -33,4 +35,5 @@ just godspeak in a variety of languages. | [C#] (😎) | `.cs` | [Powershell] | `.ps1` | | [Go] | `.go` | [Clojure] | `.clj` | | [Dart] | `.dart` | [Scala] | `.scala` | -| [R] | `.r` | [Swift] | `.swift` |
\ No newline at end of file +| [R] | `.r` | [Swift] | `.swift` | +| [Rust] | `.rs` | [Crystal] | `.cr` |
\ No newline at end of file diff --git a/src/crystal.cr b/src/crystal.cr new file mode 100644 index 0000000..96d7196 --- /dev/null +++ b/src/crystal.cr @@ -0,0 +1,2 @@ +lines = File.read("vocab.txt").split("\n") +puts lines[rand(lines.size)] diff --git a/src/rust.rs b/src/rust.rs new file mode 100644 index 0000000..9ca5801 --- /dev/null +++ b/src/rust.rs @@ -0,0 +1,11 @@ +use std::fs::File; +use std::io::{BufRead, BufReader}; + +fn main() { + let file = File::open("src/vocab.txt").unwrap(); + let reader = BufReader::new(file); + let lines = reader.lines().collect::<Result<Vec<_>, _>>().unwrap(); + let random_index = (rand::random::<f64>() * lines.len() as f64) as usize; + let random_line = &lines[random_index]; + println!("{}", random_line); +} |