Module: PatternMatching::USAGE
- Defined in:
- lib/patternmatching.rb
Overview
The module is only for showing usage…
Using module
# If installed from rubygems require “rubygems” gem “patternmatching”
# for use require “patternmatching”
Structured data example
val = 200 code = PatternMatching.build 100), val)
Partial func example
class Calc
extend PatternMatching
func(:calcm).seems as {plus(:a, :b)} do
calcm(a) + calcm(b)
end
func(:calcm).seems as {mul(:a, :b)} do
calcm(a) * calcm(b)
end
func(:calcm).seems as {:value} do
value
end
end
p Calc.new.calcm(code)
Pattern matching example
include PatternMatching
def calc(code)
make(code) {
seems as {plus(:a, :b)} do calc(a) + calc(b) end
seems as {mul(:a, :b)} do calc(a) * calc(b) end
seems something do code end
}
end
p calc(code)
For more
see README.txt