Created
October 22, 2017 22:16
-
-
Save vadixidav/a28d96fe7a02efa3f58ff5ae5f469c2f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fn fold_op<F: Fn(f64, f64)>(input: &[u8], init: f64, f: F) -> IResult<&[u8], f64> { | |
fold_many0!(ws!(alt!(apply!(list) | apply!(f64::from_str))), init, f) | |
} | |
named!(list<f64>, delimited!(tag!("("), ws!(alt!( | |
proceed!(tag!("+"), apply!(fop, 0.0, |acc, item| acc + item)) | |
)), tag!(")"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment