From Wikipedia, the free encyclopedia
Erlang係一種通用嘅函數式。Erlang都可以指Erlang/OTP嘅通稱,開源電信平台(OTP)係Erlang嘅常用執行環境同埋一系列嘅標準元件。
Erlang 執行環境係專有以下要求嘅系統設計:
Erlang程式員可以用惰性求值。但係,必須用λ演算式,先至可以做到惰性求值。
以下是惰性求值的一例:假設有個剖析器程式如下,由於同埋早求值特徵,呢個程式將唔會求解。
Expr() -> alt(then(factor(), then(literal($+), factor())), Then(factor(), then(literal($-), factor()))). Factor() -> alt(then(term(), then(literal($*), term())), Then(term(), then(literal($/), term()))). Term() -> alt(number(), Xthen(literal($(), thenx(expr(), literal($))))).
呢度用λ演算式同埋適當用函數名稱表示,就可以進行求值。示例如下。
Expr() -> Fun () -> Alt(then(fun factor/0, then(literal($+), fun factor/0)), Then(fun factor/0, then(literal($-), fun factor/0))) End. Factor() -> Fun () -> Alt(then(fun term/0, then(literal($*), fun term/0)), Then(fun term/0, then(literal($/), fun term/0))) End. Term() -> Fun () -> Alt(number(), Xthen(literal($(), thenx(expr(), literal($))))) End.
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.