Sha256: 51c07cc31cbb7ed1892616e524550007c573f17376991b0067ae6aa2f138543f

Contents?: true

Size: 358 Bytes

Versions: 1

Compression:

Stored size: 358 Bytes

Contents

require "patternmatching"


# For DSL style code, include PatternMatching
include PatternMatching

# match example
def calc(code)
  make (code) {
    seems as {plus(:x, :y)} do calc(x) + calc(y) end
    seems as {mul(:x, :y)} do  calc(x) * calc(y) end
    seems something do code end
  }
end


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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
patternmatching-0.1.0 examples/matching.rb