Erlang

From Wikipedia, the free encyclopedia

Erlang
Remove ads

Erlang係一種通用嘅函數式。Erlang都可以指Erlang/OTP嘅通稱,開源電信平台(OTP)係Erlang嘅常用執行環境同埋一系列嘅標準元件。

Quick facts 編程範式, 設計者 ...

Erlang 執行環境係專有以下要求嘅系統設計:

Remove ads

其他程式設計典範

惰性求值

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.
Remove ads

應用

Remove ads

社區

參考

睇多啲

出面網頁

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads