Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Pampy: Pattern Matching for Python. Parent comment
Oh, I like the prettier syntax:
calc_rules = alt( Int(id), rule(BinOp("+", Int(X), Int(Y)), to(lambda v: Int(v.X + v.Y))), rule(BinOp("-", Int(X), Int(Y)), to(lambda v: Int(v.X - v.Y))), rule(BinOp("*", Int(X), Int(Y)), to(lambda v: Int(v.X * v.Y))), rule(BinOp("/", Int(X), Int(Y)), to(lambda v: Int(v.X // v.Y))) )
This way of sharing variable names between the pattern and the associated action is pretty neat. It's much nicer than Pampy's use of '_' for all variables.
There are no comments on this comment yet.
Oh, I like the prettier syntax:
(https://github.com/true-grue/raddsl/blob/master/examples/cal...)This way of sharing variable names between the pattern and the associated action is pretty neat. It's much nicer than Pampy's use of '_' for all variables.