Skip to content

Commit

Permalink
add todos
Browse files Browse the repository at this point in the history
  • Loading branch information
tourtiere committed May 24, 2021
1 parent 5a62187 commit 8f351e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
Todo:
- Add arguments to exposed function.
- Add error handling for out of bounds index
- Autocheck sequence or calculator mode, by inspecting
-- Edit: no necessary

---
Rust Errors to wasm. Json?

# Fibomachine

Arbitrary long integer calculator

## Usage

```
fibomachine <Expression>
```

## Example

```
$ fibomachine "3^500/2^500"
Expand Down
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ pub mod error;
pub fn parse_first_terms(stack: &str) -> engine::Sequence {
let mut seq: engine::Sequence = Vec::new();
for term in stack.split(",") {
let number = BigInt::parse_bytes(term.as_bytes(), 10).unwrap();
let value = ast::Value::Number { value: number };
seq.push(value);
if let Some(number) = BigInt::parse_bytes(term.as_bytes(), 10) {
let value = ast::Value::Number { value: number };
seq.push(value);
}
}
seq
}
Expand Down Expand Up @@ -63,6 +64,9 @@ pub fn run(input: &str, limit: i32) -> String {
}
*/
let sequence = engine::execute(&ast, &mut first_terms, limit as usize);
/*
*/
match sequence {
Ok(sequence) => printable_sequence(sequence),
Err(err) => format!("{}", err),
Expand All @@ -81,5 +85,5 @@ fn check_fibonacci_sequence() {

#[test]
fn check_out_of_bounds_error() {
assert_eq!(run("a(n-1)+a(n-2);", 3), "error");
assert_eq!(run("a(n-1)+a(n-2);0", 3), "error");
}

0 comments on commit 8f351e2

Please sign in to comment.