Sha256: 8ac52d47754d0d2b347c56c259d9744fd179c7d167d8217ef5564c93d3e6da9e

Contents?: true

Size: 426 Bytes

Versions: 8

Compression:

Stored size: 426 Bytes

Contents

# If installed from gem
# require "rubygems"
# gem "patternmatching"
require "patternmatching"

# For DSL style code, include PatternMatching
include PatternMatching

# match example
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


code = build {plus(mul(100, 100), 200)}
p calc(code) #=> 10200

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
patternmatching-0.1.4 examples/matching.rb
patternmatching-0.2.1 examples/matching.rb
patternmatching-0.2.3 examples/matching.rb
patternmatching-0.1.1 examples/matching.rb
patternmatching-0.1.2 examples/matching.rb
patternmatching-0.1.3 examples/matching.rb
patternmatching-0.2.0 examples/matching.rb
patternmatching-0.2.2 examples/matching.rb