Created
September 5, 2019 14:22
-
-
Save SamTebbs33/9be284b69f337f7792aff010d97ea954 to your computer and use it in GitHub Desktop.
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
const std = @import("std"); | |
const fmt = std.fmt; | |
const Parser = struct { | |
input: []const u8, | |
ch: u8, | |
len: usize, | |
fn parse_factor(self: *Parser) !f64 { | |
if (self.ch == '1') | |
return -self.parse_factor(); | |
return try fmt.parseFloat(f64, self.input[0..self.len-1]); | |
} | |
}; | |
pub fn main() !void { | |
var p: Parser = undefined; | |
_ = try p.parse_factor(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment