13.07.2015 Views

BAB II LANDASAN TEORI

BAB II LANDASAN TEORI

BAB II LANDASAN TEORI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

102.2.1.3 Pre-Defined Module AttributesModul yang sudah tersedia dalam Erlang harus diletakkan sebelum deklarasifungsi apapun. Contoh :• -module(Module). %Deklarasi modul. Untuk mendefinisikan namamodul.• -export(Functions) %Mendefinisikan fungsi yang dapat digunakandiluar modul tersebut• -import(Module, Functions). %Mengambil fungsi dari modul yang lain.• -compile(Options). %Compiler options.2.2.2 Fungsi2.2.2.1 Sintak Deklarasi FungsiBentuk umum :Name(Pattern1A,…..PatternN) ->BodyA;…;Name(Pattern1B,…..PatternN) ->BodyB;…;Nama fungsi merupakan atom. Setiap argument merupakan pattern. Contoh :fact(N) when N>0 ->N * fact(N-1);% first clause head% first clause bodyfact(0) ->% second clause head1. % second clause body

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!