Sha256: 6953a7852bf455fd45163fbc222b2b5cf5143d96318676919e17abf8849927f5

Contents?: true

Size: 425 Bytes

Versions: 2

Compression:

Stored size: 425 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

2 entries across 2 versions & 1 rubygems

Version Path
patternmatching-0.2.4 examples/matching.rb
patternmatching-0.2.5 examples/matching.rb