Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Ani Programming

Name: Anonymous 2011-03-29 11:56

Name: Anonymous 2011-03-30 11:50

>>5
Nope. Comparatively sized infix calculator would look just as messy.

<: Parser for infix expressions
   Usage: parse "2*(3+4)"
:>
parseNumber [@xs] -> {:r n [x:@!digit @xs] -> r 10n+x xs; n [] -> n} 0 xs
parseOp [x:{\+; \-; \*; \/}] -> x.asSym
parseTerm x -> x.{[\( a:@Expr \)] -> [a]
                 ;[a:@Number]     -> a}
parseExpr x -> x.{[a:@Term o:@Op b:@Expr] -> [o a b]
                 ;[a:@Term]               -> a}
parse string -> string.asList.(strip \Space ?).parseExpr

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List