Skip to content

Instantly share code, notes, and snippets.

@SamTebbs33
Created September 5, 2019 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamTebbs33/9be284b69f337f7792aff010d97ea954 to your computer and use it in GitHub Desktop.
Save SamTebbs33/9be284b69f337f7792aff010d97ea954 to your computer and use it in GitHub Desktop.
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