<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>Pascal Programming</title><description></description><managingEditor>noreply@blogger.com (dazchild)</managingEditor><pubDate>Sun, 8 Sep 2024 11:45:36 -0700</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">34</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://pascalprog.blogspot.com/</link><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:subtitle/><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><title>Crypto</title><link>http://pascalprog.blogspot.com/2008/06/crypto.html</link><category>Crypto</category><category>Filetype:pas</category><category>Pas</category><category>Pascal</category><author>noreply@blogger.com (dazchild)</author><pubDate>Fri, 6 Jun 2008 02:07:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-3850326010462653614</guid><description>{&lt;br /&gt;Agung Fitriyanto        7644;&lt;br /&gt;Firman Maulana            7666;&lt;br /&gt;Tri Danarto            7806;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;program kripto;&lt;br /&gt;uses crt;&lt;br /&gt;var kata1,kata2,kata3,sandi1,sandi2,terj1,terj2,bantu:string;&lt;br /&gt;    a,b,c:char;&lt;br /&gt;    i,j,k,l:integer;&lt;br /&gt;    jalan:boolean;&lt;br /&gt;&lt;br /&gt;procedure caribinernya(var tempat:string;x:integer);&lt;br /&gt;{Procedure untuk mengubah suatu nilai integer ke bilangan biner 8 digit&lt;br /&gt; dengan format string (karena tidak ada format biner dalam pascal)untuk&lt;br /&gt; kemudian dikodekan}&lt;br /&gt;begin&lt;br /&gt; if x&gt;127 then begin tempat:=tempat+'1';x:=x-128 end else tempat:=tempat+'0';&lt;br /&gt; if x&gt;63 then begin tempat:=tempat+'1';x:=x-64 end else tempat:=tempat+'0';&lt;br /&gt; if x&gt;31 then begin tempat:=tempat+'1';x:=x-32 end else tempat:=tempat+'0';&lt;br /&gt; if x&gt;15 then begin tempat:=tempat+'1';x:=x-16 end else tempat:=tempat+'0';&lt;br /&gt; if x&gt;7 then begin tempat:=tempat+'1';x:=x-8 end else tempat:=tempat+'0';&lt;br /&gt; if x&gt;3 then begin tempat:=tempat+'1';x:=x-4 end else tempat:=tempat+'0';&lt;br /&gt; if x&gt;1 then begin tempat:=tempat+'1';x:=x-2 end else tempat:=tempat+'0';&lt;br /&gt; if x=1 then begin tempat:=tempat+'1';x:=x-1 end else tempat:=tempat+'0';&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure cariintegernya(x:string;var y:integer);&lt;br /&gt;{Procedure untuk mengubah suatu nilai biner (dalam variabel berbentuk string)&lt;br /&gt; ke suatu nilai integernya dengan basis 10}&lt;br /&gt;var anu:integer;&lt;br /&gt;begin&lt;br /&gt;  y:=0;&lt;br /&gt;  if x[1]='1' then y:=y+128;&lt;br /&gt;  if x[2]='1' then y:=y+64;&lt;br /&gt;  if x[3]='1' then y:=y+32;&lt;br /&gt;  if x[4]='1' then y:=y+16;&lt;br /&gt;  if x[5]='1' then y:=y+8;&lt;br /&gt;  if x[6]='1' then y:=y+4;&lt;br /&gt;  if x[7]='1' then y:=y+2;&lt;br /&gt;  if x[8]='1' then y:=y+1;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure acak(x:string;var y:string);&lt;br /&gt;{Procedure untuk pengkodean dengan subsitusi}&lt;br /&gt;begin&lt;br /&gt; if x='000' then y:='010';&lt;br /&gt; if x='001' then y:='011';&lt;br /&gt; if x='010' then y:='100';&lt;br /&gt; if x='011' then y:='101';&lt;br /&gt; if x='100' then y:='110';&lt;br /&gt; if x='101' then y:='111';&lt;br /&gt; if x='110' then y:='000';&lt;br /&gt; if x='111' then y:='001';&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure acak2(x:string;var y:string);&lt;br /&gt;{Procedure untuk penerjemahan balik dari suatu kode}&lt;br /&gt;begin&lt;br /&gt; if x='000' then y:='110';&lt;br /&gt; if x='001' then y:='111';&lt;br /&gt; if x='010' then y:='000';&lt;br /&gt; if x='011' then y:='001';&lt;br /&gt; if x='100' then y:='010';&lt;br /&gt; if x='101' then y:='011';&lt;br /&gt; if x='110' then y:='100';&lt;br /&gt; if x='111' then y:='101';&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;clrscr;&lt;br /&gt;kata1:='';&lt;br /&gt;while kata1='' do&lt;br /&gt;begin&lt;br /&gt;  write(' Kata yang mau diacak = ');{Kata yang mau dikodekan}&lt;br /&gt;  readln(kata1);&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;jalan:=true;&lt;br /&gt;while jalan do&lt;br /&gt; begin&lt;br /&gt; a:=kata1[1];{ambil karakter terdepan}&lt;br /&gt; i:=ord(a);{cari nilai ASCII-nya}&lt;br /&gt; caribinernya(sandi1,i);{ubah ke bentuk biner 8 digit}&lt;br /&gt; while length(sandi1)&gt;=3 do {dipotong per-3 untuk dikodekan}&lt;br /&gt;  begin&lt;br /&gt;  terj1:=sandi1[1]+sandi1[2]+sandi1[3];{ambil 3 karakter terdepan}&lt;br /&gt;  acak(terj1,terj2);{pengkodean tiga karakter tadi}&lt;br /&gt;  sandi2:=sandi2+terj2; {hasil pengkodean disimpan di sandi2}&lt;br /&gt;  delete(sandi1,1,3);{tiga karakter terdepan yang sudah dikodekan dihapus}&lt;br /&gt;  end;&lt;br /&gt;&lt;br /&gt; while length(sandi2)&gt;=8 do {hasil pengkodean (sandi2) di terjemahkan ke&lt;br /&gt;  kode ASCII kembali per 8 digit (1 karakter)}&lt;br /&gt;  begin&lt;br /&gt;  bantu:='';&lt;br /&gt;  for j:=1 to 8 do bantu:=bantu+sandi2[j];{8 karakter terdepan diambil}&lt;br /&gt;  cariintegernya(bantu,k);{8 digit bilangan dicari nilai integernya}&lt;br /&gt;  kata2:=kata2+char(k);{hasil pengkodean di masukkan ke kata2}&lt;br /&gt;  delete(sandi2,1,8);{8 karakter yang sudah dikodekan dihapus}&lt;br /&gt;  end;&lt;br /&gt; delete(kata1,1,1);{hapus karakter terdepan dari kata1}&lt;br /&gt; if kata1='' then jalan:=false;{perulangan berhenti jika kata sudah habis}&lt;br /&gt; end;&lt;br /&gt;&lt;br /&gt; {Percabangan di bawah ini digunakan jika ternyata jumlah karakter yang&lt;br /&gt;  mau dikodekan bukan kelipatan 3 sehingga ada kekurangn digit pada&lt;br /&gt;  terjemahan per-3 digit}&lt;br /&gt; if sandi1&lt;&gt;'' then {Sandi1 masih menyisakan karakter yang belum dikodekan}&lt;br /&gt;  begin&lt;br /&gt;  l:=0;&lt;br /&gt;  while length(sandi1)&lt;3 do&lt;br /&gt;   begin&lt;br /&gt;   sandi1:=sandi1+'0';&lt;br /&gt;   l:=l+1;{l merupakan jumlah karakter yang ditambahkan agar genap 3 digit}&lt;br /&gt;   end;&lt;br /&gt;  terj1:=sandi1;sandi1:='';&lt;br /&gt;  acak(terj1,terj2);&lt;br /&gt;  sandi2:=sandi2+terj2;&lt;br /&gt;  if length(sandi2)&gt;8 then delete(sandi2,9,l);{setelah dikodekan sandi2&lt;br /&gt;  dipotong sebanyak penambahannya}&lt;br /&gt;  cariintegernya(sandi2,k);&lt;br /&gt;  kata2:=kata2+char(k);&lt;br /&gt;  end;&lt;br /&gt; writeln(' Kode yang dihasilkan = ',kata2); {Kode final}&lt;br /&gt; readln;&lt;br /&gt;{Untuk jumlah karakter kata1 yang tidak kelipatan 3 maka akan mengakibatkan&lt;br /&gt;sandi1 sebagai variabel penyimpan bilangan-bilangan biner yang akan dikodekan&lt;br /&gt;masih menyimpan beberapa digit sisa, sehingga harus ditambahkan suatu bilangan&lt;br /&gt;ada 2 kemungkinan pada terjemahan per-3 yaitu kurang 1 digit atau 2 digit.&lt;br /&gt;Untuk itu ditambahkan suatu bilangan di belakangnya sehingga:&lt;br /&gt; xx0 --&gt; 000 menjadi 010 atau 00_ menjadi 01_&lt;br /&gt;         010 menjadi 100 atau 01_ menjadi 10_&lt;br /&gt;         100 menjadi 110 atau 10_ menjadi 11_&lt;br /&gt;         110 menjadi 000 atau 11_ menjadi 00_&lt;br /&gt; x00 --&gt; 000 menjadi 010 atau 0__ menjadi 0__&lt;br /&gt;         100 menjadi 110 atau 1__ menjadi 1__&lt;br /&gt; kemudian setelah pengacakan 3 digit bilangan tersebut pada penerjemahan ke&lt;br /&gt; bilangan ASCII dipotong kembali pada digit belakang sesuai jumlah penambahan&lt;br /&gt;&lt;br /&gt;Sedangkan untuk penerjemahan balik dari suatu kode maka tentunya akan mengalami&lt;br /&gt;kendala yang sama, tapi pada digit yang kurang tersebut ditambahkan bilagan 1&lt;br /&gt;sehingga :&lt;br /&gt; xx1 --&gt; 001 dibaca 111 atau 00_ menjadi 11_&lt;br /&gt;         011 dibaca 001 atau 01_ menjadi 00_&lt;br /&gt;         101 dibaca 011 atau 10_ menjadi 01_&lt;br /&gt;         111 dibaca 101 atau 11_ menjadi 10_&lt;br /&gt; x11 --&gt; 011 dibaca 001 atau 0__ menjadi 0__&lt;br /&gt;         111 dibaca 101 atau 1__ menjadi 1__&lt;br /&gt;&lt;br /&gt; Dengan metode diatas terjadi kesesuaian dengan penambahan bilangan 0 pada&lt;br /&gt; saat pengkodean.&lt;br /&gt; Untuk membuktikan hal tersebut di bawah ini dibuat sebuah pengkodean balik&lt;br /&gt; dari kode yang sudah dibuat diatas dengan cara seperti yang sudah disebutkan&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;jalan:=true;sandi1:='';sandi2:='';&lt;br /&gt;while jalan do&lt;br /&gt; begin&lt;br /&gt; a:=kata2[1];&lt;br /&gt; i:=ord(a);&lt;br /&gt; caribinernya(sandi1,i);&lt;br /&gt; while length(sandi1)&gt;=3 do&lt;br /&gt;  begin&lt;br /&gt;  terj1:=sandi1[1]+sandi1[2]+sandi1[3];&lt;br /&gt;  acak2(terj1,terj2);&lt;br /&gt;  sandi2:=sandi2+terj2;&lt;br /&gt;  delete(sandi1,1,3);&lt;br /&gt;  end;&lt;br /&gt;&lt;br /&gt; while length(sandi2)&gt;=8 do&lt;br /&gt;  begin&lt;br /&gt;  bantu:='';&lt;br /&gt;  for j:=1 to 8 do bantu:=bantu+sandi2[j];&lt;br /&gt;  cariintegernya(bantu,k);&lt;br /&gt;  kata3:=kata3+char(k);&lt;br /&gt;  delete(sandi2,1,8);&lt;br /&gt;  end;&lt;br /&gt; delete(kata2,1,1);&lt;br /&gt; if kata2='' then jalan:=false;&lt;br /&gt; end;&lt;br /&gt;&lt;br /&gt; if sandi1&lt;&gt;'' then&lt;br /&gt;  begin&lt;br /&gt;  l:=0;&lt;br /&gt;  while length(sandi1)&lt;3 do&lt;br /&gt;   begin&lt;br /&gt;   sandi1:=sandi1+'1';&lt;br /&gt;   l:=l+1;&lt;br /&gt;   end;&lt;br /&gt;  terj1:=sandi1;sandi1:='';&lt;br /&gt;  acak2(terj1,terj2);&lt;br /&gt;  sandi2:=sandi2+terj2;&lt;br /&gt;  if length(sandi2)&gt;8 then delete(sandi2,9,l);&lt;br /&gt;  cariintegernya(sandi2,k);&lt;br /&gt;  kata3:=kata3+char(k);&lt;br /&gt;  end;&lt;br /&gt; writeln(' Kode yang dibalikkan = ',kata3);&lt;br /&gt; readln;&lt;br /&gt;end.</description></item><item><title>Ember Queue</title><link>http://pascalprog.blogspot.com/2008/06/ember-queue.html</link><category>Ember</category><category>Filetype:pas</category><category>Pas</category><category>Queue</category><category>Record</category><author>noreply@blogger.com (dazchild)</author><pubDate>Fri, 6 Jun 2008 02:05:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-4805511814569011009</guid><description>Program Ember;&lt;br /&gt;&lt;br /&gt;Const&lt;br /&gt;    QUEUE_SIZE  = 1000000;&lt;br /&gt;    MaxA        = 4;&lt;br /&gt;    MaxB        = 3;&lt;br /&gt;&lt;br /&gt;Type&lt;br /&gt;    TQueue  = Record&lt;br /&gt;        Sebelumnya  : LongInt;&lt;br /&gt;        Langkah     : Byte;&lt;br /&gt;        A, B        : Integer;&lt;br /&gt;    End;&lt;br /&gt;       &lt;br /&gt;Var&lt;br /&gt;    Queue   : Array[0..QUEUE_SIZE] of TQueue;&lt;br /&gt;    Langkah : Array[1..QUEUE_SIZE] of Byte;&lt;br /&gt;    QPos    : LongInt;&lt;br /&gt;    QNext   : LongInt;&lt;br /&gt;    A1, B1  : Integer;&lt;br /&gt;    A2, B2  : Integer;&lt;br /&gt;    i, j    : LongInt;&lt;br /&gt;&lt;br /&gt;Procedure Proses;&lt;br /&gt;Begin&lt;br /&gt;&lt;br /&gt;    QPos := 0;&lt;br /&gt;    QNext := 0;&lt;br /&gt;&lt;br /&gt;    Queue[QPos].Langkah := 0;&lt;br /&gt;    Queue[QPos].A := A1;&lt;br /&gt;    Queue[QPos].B := B1;&lt;br /&gt;&lt;br /&gt;    While True do&lt;br /&gt;    Begin&lt;br /&gt;        If (Queue[QPos].A = A2) And (Queue[QPos].B = B2) Then&lt;br /&gt;            Break;&lt;br /&gt;       &lt;br /&gt;        { A diisi penuh --&gt; hanya jika A belum penuh}&lt;br /&gt;        If Queue[QPos].A &lt; MaxA Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := MaxA;&lt;br /&gt;            Queue[QNext].B := Queue[QPos].B;&lt;br /&gt;            Queue[QNext].Langkah := 1;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;       &lt;br /&gt;        { B diisi penuh --&gt; hanya jika B belum penuh }&lt;br /&gt;        If Queue[QPos].B &lt; MaxB Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := Queue[QPos].A;&lt;br /&gt;            Queue[QNext].B := MaxB;&lt;br /&gt;            Queue[QNext].Langkah := 2;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;       &lt;br /&gt;        { A dikosongkan --&gt; hanya jika A tidak kosong }&lt;br /&gt;        If Queue[QPos].A &gt; 0 Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := 0;&lt;br /&gt;            Queue[QNext].B := Queue[QPos].B;&lt;br /&gt;            Queue[QNext].Langkah := 3;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;       &lt;br /&gt;        { B dikosongkan --&gt; hanya jika B tidak kosong }&lt;br /&gt;        If Queue[QPos].B &gt; 0 Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := Queue[QPos].A;&lt;br /&gt;            Queue[QNext].B := 0;&lt;br /&gt;            Queue[QNext].Langkah := 4;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;       &lt;br /&gt;        { A dipindahkan ke B sampai A kosong --&gt; hanya jika MaxB-B &gt;= A }&lt;br /&gt;        If MaxB - Queue[QPos].B &gt;= Queue[QPos].A Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := 0;&lt;br /&gt;            Queue[QNext].B := Queue[QPos].B + Queue[QPos].A;&lt;br /&gt;            Queue[QNext].Langkah := 5;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;       &lt;br /&gt;        { A dipindahkan ke B sampai B penuh --&gt; hanya jika MaxB-B &lt; A }&lt;br /&gt;        If MaxB - Queue[QPos].B &lt; Queue[QPos].A Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := Queue[QPos].A - (MaxB - Queue[QPos].B);&lt;br /&gt;            Queue[QNext].B := MaxB;&lt;br /&gt;            Queue[QNext].Langkah := 6;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;&lt;br /&gt;        { B dipindahkan ke A sampai B kosong --&gt; hanya jika MaxA-A &gt;= B }&lt;br /&gt;        If MaxA - Queue[QPos].A &gt;= Queue[QPos].B Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := Queue[QPos].A + Queue[QPos].B;&lt;br /&gt;            Queue[QNext].B := 0;&lt;br /&gt;            Queue[QNext].Langkah := 7;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;       &lt;br /&gt;        { A dipindahkan ke B sampai A penuh --&gt; hanya jika MaxA-A &lt; B }&lt;br /&gt;        If MaxA - Queue[QPos].A &lt; Queue[QPos].B Then&lt;br /&gt;        Begin&lt;br /&gt;            QNext := QNext + 1;&lt;br /&gt;            Queue[QNext].A := MaxA;&lt;br /&gt;            Queue[QNext].B := Queue[QPos].B - (MaxA - Queue[QPos].A);&lt;br /&gt;            Queue[QNext].Langkah := 8;&lt;br /&gt;            Queue[QNext].Sebelumnya := QPos;&lt;br /&gt;        End;&lt;br /&gt;&lt;br /&gt;        QPos := QPos + 1;&lt;br /&gt;    End;&lt;br /&gt;&lt;br /&gt;    i := 1;&lt;br /&gt;    While True do&lt;br /&gt;    Begin&lt;br /&gt;        Langkah[i] := Queue[QPos].Langkah;&lt;br /&gt;        i := i + 1;&lt;br /&gt;        QPos := Queue[QPos].Sebelumnya;&lt;br /&gt;        If QPos = 0 Then&lt;br /&gt;            Break;&lt;br /&gt;    End;&lt;br /&gt;&lt;br /&gt;    For j := i DownTo 1 do&lt;br /&gt;    Begin&lt;br /&gt;        Case Langkah[j] of&lt;br /&gt;        1: WriteLn('A diisi penuh');&lt;br /&gt;        2: WriteLn('B diisi penuh');&lt;br /&gt;        3: WriteLn('A dikosongkan');&lt;br /&gt;        4: WriteLn('B dikosongkan');&lt;br /&gt;        5: WriteLn('A dipindahkan ke B sampai A kosong');&lt;br /&gt;        6: WriteLn('A dipindahkan ke B sampai B penuh');&lt;br /&gt;        7: WriteLn('B dipindahkan ke A sampai B kosong');&lt;br /&gt;        8: WriteLn('B dipindahkan ke A sampai A penuh');&lt;br /&gt;        End;&lt;br /&gt;    End;&lt;br /&gt;&lt;br /&gt;End;&lt;br /&gt;&lt;br /&gt;Begin&lt;br /&gt;&lt;br /&gt;    { Kondisi Awal }&lt;br /&gt;    A1 := 0;&lt;br /&gt;    B1 := 0;&lt;br /&gt;&lt;br /&gt;    { Kondisi Akhir }&lt;br /&gt;    A2 := 2;&lt;br /&gt;    B2 := 0;&lt;br /&gt;   &lt;br /&gt;    { Proses }&lt;br /&gt;    Proses;&lt;br /&gt;&lt;br /&gt;End.</description></item><item><title>Binary Search Tree 2</title><link>http://pascalprog.blogspot.com/2008/06/binary-search-tree-2.html</link><category>Binary Tree</category><category>Binasry Search Tree</category><category>Pas</category><category>Tree</category><author>noreply@blogger.com (dazchild)</author><pubDate>Thu, 5 Jun 2008 00:10:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-4882627669495732641</guid><description>{Searches a binary search tree in O(logn) }&lt;br /&gt;&lt;br /&gt;type tree = ^ node;&lt;br /&gt;    node = record&lt;br /&gt;      left, right : tree;&lt;br /&gt;      info : char&lt;br /&gt;    end;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function subtree( item : char ) : tree;&lt;br /&gt;{creates a subtree}&lt;br /&gt;var t : tree;&lt;br /&gt;begin&lt;br /&gt;    new( t );&lt;br /&gt;    t^.info := item;&lt;br /&gt;    t^.left := nil;&lt;br /&gt;    t^.right := nil;&lt;br /&gt;    subtree := t&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure infix( t : tree);&lt;br /&gt;begin&lt;br /&gt;    if t &lt;&gt; nil then begin&lt;br /&gt;       infix( t^.left );&lt;br /&gt;       write( t^.info );&lt;br /&gt;       infix( t^.right )&lt;br /&gt;    end&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;procedure prefix( t : tree);&lt;br /&gt;begin&lt;br /&gt;    if t &lt;&gt; nil then begin&lt;br /&gt;       write( t^.info );&lt;br /&gt;       prefix( t^.left );&lt;br /&gt;       prefix( t^.right )&lt;br /&gt;    end&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure postfix( t : tree);&lt;br /&gt;begin&lt;br /&gt;    if t &lt;&gt; nil then begin&lt;br /&gt;       postfix( t^.left );&lt;br /&gt;       postfix( t^.right );&lt;br /&gt;       write( t^.info );&lt;br /&gt;    end&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure insert( item : char; var t : tree );&lt;br /&gt;begin&lt;br /&gt;    if t = nil then&lt;br /&gt;       t := subtree( item )&lt;br /&gt;    else if item &lt;= t^.info then         insert( item, t^.left)      else         insert( item, t^.right) end;  procedure bst( var root : tree ); {produces a binary search tree} var item : char; begin      writeln('type your sentence');      root := nil;      while not eoln do begin            read( item );            insert( item, root )      end end; procedure search( key: char; var found: boolean; t : tree); begin        if (t &lt;&gt; nil) and not found then begin&lt;br /&gt;           if key = t^.info then&lt;br /&gt;               found := true&lt;br /&gt;           else if key &lt; t^.info then&lt;br /&gt;               search(key, found, t^.left)&lt;br /&gt;           else&lt;br /&gt;               search(key, found, t^.right)&lt;br /&gt;      end&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;var root : tree;&lt;br /&gt;   found : boolean;&lt;br /&gt;   key : char;&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;       bst( root );&lt;br /&gt;       infix( root );&lt;br /&gt;       writeln;&lt;br /&gt;       readln;&lt;br /&gt;       writeln( 'type your letter');&lt;br /&gt;       found := false;&lt;br /&gt;       readln( key );&lt;br /&gt;       search( key, found, root);&lt;br /&gt;       if found then&lt;br /&gt;         writeln( key, ' was found.')&lt;br /&gt;       else&lt;br /&gt;         writeln( key, ' was not found.');&lt;br /&gt;       readln;&lt;br /&gt;       readln&lt;br /&gt;&lt;br /&gt;end.</description></item><item><title>Binary Search</title><link>http://pascalprog.blogspot.com/2008/06/binary-search.html</link><category>Binary Search</category><category>Biner</category><category>Pencarian</category><author>noreply@blogger.com (dazchild)</author><pubDate>Thu, 5 Jun 2008 00:08:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-4571872458887678382</guid><description>{Performs a binary search}&lt;br /&gt;TYPE&lt;br /&gt;      tree =^node;&lt;br /&gt;      node = record&lt;br /&gt;           info : char;&lt;br /&gt;           left, right : tree&lt;br /&gt;      end;&lt;br /&gt;VAR root: tree;&lt;br /&gt;    Number: integer;&lt;br /&gt;{$I Tree }&lt;br /&gt;{Activates: Binary_Tree, Infix, subTree, Height}&lt;br /&gt;&lt;br /&gt;procedure search( t : tree; var found : boolean; x : char);&lt;br /&gt;{pre: t points to a tree&lt;br /&gt; post : each node is visited and there n is incremented}&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;     if (t &lt;&gt; nil) and not found then&lt;br /&gt;        if x = t^.info then begin&lt;br /&gt;           found := true;&lt;br /&gt;           writeln( x, ' was found')&lt;br /&gt;          end&lt;br /&gt;        else if x &lt; t^.info then&lt;br /&gt;             search( t^.left, found, x)&lt;br /&gt;        else&lt;br /&gt;             search( t^.right, found, x)&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;var found: boolean;&lt;br /&gt;    x : char;&lt;br /&gt;BEGIN{main}&lt;br /&gt;           Binary_Tree(root);&lt;br /&gt;           Infix(root);&lt;br /&gt;           writeln;&lt;br /&gt;           found := false;&lt;br /&gt;           writeln('What value of x do you want?');&lt;br /&gt;           readln( x );&lt;br /&gt;           search( root, found, x);&lt;br /&gt;           writeln(x, ' was found is ', found)&lt;br /&gt;END.</description></item><item><title>Tree</title><link>http://pascalprog.blogspot.com/2008/06/tree.html</link><category>Binary Tree</category><category>InOrder</category><category>InOrderTree</category><category>Pas</category><category>PostOrder</category><category>PostOrderTree</category><category>PreOrder</category><category>PreOrderTree</category><category>Tree</category><author>noreply@blogger.com (dazchild)</author><pubDate>Thu, 5 Jun 2008 00:05:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-8540845958448812266</guid><description>PROGRAM Tree (Input, Output);&lt;br /&gt;{Written by Jason John Schwarz with Turbo Pascal v6.0.&lt;br /&gt;Purpose: A demonstration binary tree.}&lt;br /&gt;&lt;br /&gt;USES CRT;&lt;br /&gt;&lt;br /&gt;TYPE&lt;br /&gt;   Point = ^Node;&lt;br /&gt;   Node = RECORD&lt;br /&gt;          Data : REAL;&lt;br /&gt;          Left : Point;&lt;br /&gt;          Right : Point;&lt;br /&gt;   END;{Node}&lt;br /&gt;&lt;br /&gt;VAR&lt;br /&gt;  Root : Point;&lt;br /&gt;&lt;br /&gt;PROCEDURE Initialize;&lt;br /&gt;BEGIN&lt;br /&gt;    Root:=NIL;&lt;br /&gt;END;{Initialize}&lt;br /&gt;&lt;br /&gt;PROCEDURE Create (Data : REAL);&lt;br /&gt;BEGIN&lt;br /&gt;    NEW(Root);&lt;br /&gt;    Root^.Data:=Data;&lt;br /&gt;    Root^.Left:=NIL;&lt;br /&gt;    Root^.Right:=NIL;&lt;br /&gt;END;{Create}&lt;br /&gt;&lt;br /&gt;PROCEDURE AddNode (Data :REAL; Root : Point);&lt;br /&gt;VAR&lt;br /&gt;  Temp : Point;&lt;br /&gt;BEGIN&lt;br /&gt;    NEW(Temp);&lt;br /&gt;    IF Data&gt;=Root^.Data THEN Root^.Right:=Temp;&lt;br /&gt;    IF Data&lt;root^.data procedure="" add="" root="" then="" else="" begin="" if="" data=""&gt;=Root^.Data) THEN&lt;br /&gt;             IF Root^.Right&lt;&gt;NIL THEN Add(Data,Root^.Right)&lt;br /&gt;             ELSE AddNode(Data,Root);&lt;br /&gt;          IF (Data&lt;root^.data) then="" if="" left=""&gt;&lt;&gt;NIL THEN Add(Data,Root^.Left)&lt;br /&gt;             ELSE AddNode(Data,Root);&lt;br /&gt;    END;{Root=NIL}&lt;br /&gt;END;{Add}&lt;br /&gt;&lt;br /&gt;PROCEDURE InOrder (Root : Point);&lt;br /&gt;BEGIN&lt;br /&gt;    IF Root &lt;&gt; NIL THEN BEGIN&lt;br /&gt;       InOrder(Root^.Left);&lt;br /&gt;       WRITELN(Root^.Data);&lt;br /&gt;       InOrder(Root^.Right);&lt;br /&gt;    END;{Root&lt;&gt;NIL}&lt;br /&gt;END;{InOrder}&lt;br /&gt;&lt;br /&gt;PROCEDURE PreOrder (Root : Point);&lt;br /&gt;BEGIN&lt;br /&gt;    IF Root &lt;&gt; NIL THEN BEGIN&lt;br /&gt;       WRITELN(Root^.Data);&lt;br /&gt;       PreOrder(Root^.Left);&lt;br /&gt;       PreOrder(Root^.Right);&lt;br /&gt;    END;{Root&lt;&gt;NIL}&lt;br /&gt;END;{PreOrder}&lt;br /&gt;&lt;br /&gt;PROCEDURE PostOrder (Root : Point);&lt;br /&gt;BEGIN&lt;br /&gt;    IF Root&lt;&gt;NIL THEN BEGIN&lt;br /&gt;       PostOrder(Root^.Left);&lt;br /&gt;       PostOrder(Root^.Right);&lt;br /&gt;       WRITELN(Root^.Data);&lt;br /&gt;    END;{Root&lt;&gt;NIL}&lt;br /&gt;END;{PostOrder}&lt;br /&gt;&lt;br /&gt;PROCEDURE GetData;&lt;br /&gt;VAR Data : REAL;&lt;br /&gt;BEGIN&lt;br /&gt;    WRITE(Output,'What is the new number?');&lt;br /&gt;    READLN(Input,Data);&lt;br /&gt;    Add(Data,Root);&lt;br /&gt;END;{GetData}&lt;br /&gt;&lt;br /&gt;PROCEDURE Loop;&lt;br /&gt;VAR&lt;br /&gt;  Choice : CHAR;&lt;br /&gt;BEGIN&lt;br /&gt;    REPEAT&lt;br /&gt;          Choice:=CHR(0);&lt;br /&gt;          GetData;&lt;br /&gt;          CLRSCR;&lt;br /&gt;          WRITELN(Output,'InOrder Tree:');&lt;br /&gt;          InOrder(Root);&lt;br /&gt;          WRITELN(Output,'PostOrder Tree:');&lt;br /&gt;          PostOrder(Root);&lt;br /&gt;          WRITELN(Output,'PreOrder Tree:');&lt;br /&gt;          PreOrder(Root);&lt;br /&gt;          WRITE(Output,'Do you wish to add another number?');&lt;br /&gt;          READLN(Input,Choice);&lt;br /&gt;    UNTIL Choice IN ['N','n'];&lt;br /&gt;END;{Loop}&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;    Initialize;&lt;br /&gt;    Loop;&lt;br /&gt;END.&lt;br /&gt;&lt;/root^.data)&gt;&lt;/root^.data&gt;</description></item><item><title>Binary Search Tree</title><link>http://pascalprog.blogspot.com/2008/06/binary-search-tree.html</link><category>Binary Seacrh</category><category>Binasry Search Tree</category><category>Tree</category><author>noreply@blogger.com (dazchild)</author><pubDate>Thu, 5 Jun 2008 00:03:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-2237898348233265861</guid><description>(**************************************************************)&lt;br /&gt;(*******           BINARY SEARCH TREE ADT              ********)&lt;br /&gt;(**************************************************************)&lt;br /&gt;&lt;br /&gt;TYPE&lt;br /&gt;  KeyType          = Integer; (* the type of key in Info part *)&lt;br /&gt;&lt;br /&gt;  TreeElementType  = RECORD   (* the type of the user's data  *)&lt;br /&gt;    Key  : KeyType;&lt;br /&gt;    (* other fields as needed. *)&lt;br /&gt;  END;   (* TreeElementType *)&lt;br /&gt;&lt;br /&gt;  TreePtrType = ^TreeNodeType;&lt;br /&gt;&lt;br /&gt;  TreeNodeType = RECORD&lt;br /&gt;    Info  : TreeElementType;  (* the user's data        *)&lt;br /&gt;    Left  : TreePtrType;      (* pointer to left child  *)&lt;br /&gt;    Right : TreePtrType       (* pointer to right child *)&lt;br /&gt;  END; (* TreeNodeType *)&lt;br /&gt;&lt;br /&gt;  TreeType = TreePtrType;&lt;br /&gt;&lt;br /&gt;  TraversalType = (Preorder, Inorder, Postorder);&lt;br /&gt;&lt;br /&gt;(******************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE CreateTree&lt;br /&gt;  (VAR Tree : TreeType);&lt;br /&gt;&lt;br /&gt;  (* Initializes Tree to empty state. *)&lt;br /&gt;&lt;br /&gt;BEGIN (* CreateTree *)&lt;br /&gt;  Tree := NIL&lt;br /&gt;END;  (* CreateTree *)&lt;br /&gt;&lt;br /&gt;(*************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE FindNode&lt;br /&gt;  (        Tree  : TreeType;&lt;br /&gt;       KeyValue  : KeyType;&lt;br /&gt;   VAR  NodePtr  : TreePtrType;&lt;br /&gt;   VAR ParentPtr : TreePtrType);&lt;br /&gt;&lt;br /&gt;  (* Find the node that contains KeyValue; set NodePtr to    *)&lt;br /&gt;  (* point to the node and ParentPtr to point to its parent; *)&lt;br /&gt;&lt;br /&gt;VAR&lt;br /&gt;  Found : Boolean;  (* KeyValue found in tree? *)&lt;br /&gt;&lt;br /&gt;BEGIN (* FindNode *)&lt;br /&gt;&lt;br /&gt;  (* Set up to search. *)&lt;br /&gt;  NodePtr   := Tree;&lt;br /&gt;  ParentPtr := NIL;&lt;br /&gt;  Found     := False;&lt;br /&gt;&lt;br /&gt;  (* Search until no more nodes to search or until found. *)&lt;br /&gt;  WHILE (NodePtr &lt;&gt; NIL) AND NOT Found DO&lt;br /&gt;    IF NodePtr^.Info.Key = KeyValue&lt;br /&gt;      THEN Found := True&lt;br /&gt;&lt;br /&gt;      ELSE (* Advance pointers. *)&lt;br /&gt;        BEGIN&lt;br /&gt;&lt;br /&gt;          ParentPtr := NodePtr;&lt;br /&gt;&lt;br /&gt;          IF NodePtr^.Info.Key &gt; KeyValue&lt;br /&gt;            THEN NodePtr := NodePtr^.Left&lt;br /&gt;            ELSE NodePtr := NodePtr^.Right&lt;br /&gt;&lt;br /&gt;        END (* advance pointers *)&lt;br /&gt;END; (* FindNode *)&lt;br /&gt;&lt;br /&gt;(********************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE RetrieveElement&lt;br /&gt;  (Tree            : TreeType;&lt;br /&gt;   KeyValue        : KeyType;&lt;br /&gt;   VAR Element     : TreeElementType;&lt;br /&gt;   VAR ValueInTree : Boolean);&lt;br /&gt;&lt;br /&gt;  (* Searches the binary search tree for the element whose *)&lt;br /&gt;  (* key is KeyValue, and returns a copy of the element.   *)&lt;br /&gt;&lt;br /&gt;VAR&lt;br /&gt;  NodePtr   : TreePtrType; (* pointer to node with KeyValue *)&lt;br /&gt;  ParentPtr : TreePtrType; (* used for FindNode interface   *)&lt;br /&gt;&lt;br /&gt;BEGIN (* RetrieveElement *)&lt;br /&gt;&lt;br /&gt;  (* Find node in tree that contains KeyValue. *)&lt;br /&gt;  FindNode (Tree, KeyValue, NodePtr, ParentPtr);&lt;br /&gt;&lt;br /&gt;  ValueInTree := (NodePtr &lt;&gt; NIL);&lt;br /&gt;&lt;br /&gt;  IF ValueInTree&lt;br /&gt;    THEN Element := NodePtr^.Info&lt;br /&gt;&lt;br /&gt;END;  (* RetrieveElement *)&lt;br /&gt;&lt;br /&gt;(***********************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE ModifyElement&lt;br /&gt;  (VAR Tree   : TreeType;&lt;br /&gt;   ModElement : TreeElementType);&lt;br /&gt;&lt;br /&gt;  (* ModElement replaces existing tree element with same key. *)&lt;br /&gt;VAR&lt;br /&gt;  NodePtr   : TreePtrType; (* pointer to node with KeyValue *)&lt;br /&gt;  ParentPtr : TreePtrType; (* used for FindNode interface   *)&lt;br /&gt;&lt;br /&gt;BEGIN (* ModifyElement *)&lt;br /&gt;&lt;br /&gt;  (* Find the node with the same key as ModElement.Key. *)&lt;br /&gt;  FindNode (Tree, ModElement.Key, NodePtr, ParentPtr);&lt;br /&gt;&lt;br /&gt;  (* NodePtr points to the tree node with same key. *)&lt;br /&gt;  NodePtr^.Info := ModElement&lt;br /&gt;&lt;br /&gt;END;  (* ModifyElement *)&lt;br /&gt;&lt;br /&gt;(***************************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE InsertElement&lt;br /&gt;  (VAR Tree : TreeType;&lt;br /&gt;   Element  : TreeElementType);&lt;br /&gt;&lt;br /&gt;  (* Add Element to the binary search tree. Assumes that no *)&lt;br /&gt;  (* element with the same key exists in the tree.          *)&lt;br /&gt;&lt;br /&gt;VAR&lt;br /&gt;  NewNode   : TreePtrType;  (* pointer to new node         *)&lt;br /&gt;  NodePtr   : TreePtrType;  (* used for FindNode call      *)&lt;br /&gt;  ParentPtr : TreePtrType;  (* points to new node's parent *)&lt;br /&gt;&lt;br /&gt;BEGIN (* InsertElement *)&lt;br /&gt;&lt;br /&gt;  (* Create a new node. *)&lt;br /&gt;  New (NewNode);&lt;br /&gt;  NewNode^.Left  := NIL;&lt;br /&gt;  NewNode^.Right := NIL;&lt;br /&gt;  NewNode^.Info  := Element;&lt;br /&gt;&lt;br /&gt;  (* Search for the insertion place. *)&lt;br /&gt;  FindNode (Tree, Element.Key, NodePtr, ParentPtr);&lt;br /&gt;&lt;br /&gt;  (* IF this is first node in tree, set Tree to NewNode; *)&lt;br /&gt;  (* otherwise, link new node to Node(ParentPtr).        *)&lt;br /&gt;  IF ParentPtr = NIL&lt;br /&gt;    THEN Tree := NewNode  (* first node in the tree *)&lt;br /&gt;    ELSE (* Add to the existing tree. *)&lt;br /&gt;      IF ParentPtr^.Info.Key &gt; Element.Key&lt;br /&gt;        THEN ParentPtr^.Left  := NewNode&lt;br /&gt;        ELSE ParentPtr^.Right := NewNode&lt;br /&gt;&lt;br /&gt;END; (* InsertElement *)&lt;br /&gt;&lt;br /&gt;(**********************************************************)&lt;br /&gt;{ The following code has been commented out:&lt;br /&gt;PROCEDURE InsertElement&lt;br /&gt;  (VAR Tree  : TreeType;&lt;br /&gt;   Element   : TreeElementType);&lt;br /&gt;&lt;br /&gt;   (* Recursive version of InsertElement operation. *)&lt;br /&gt;&lt;br /&gt;BEGIN (* InsertElement *)&lt;br /&gt;&lt;br /&gt;  IF Tree = NIL&lt;br /&gt;    THEN  (* Base Case: allocate new leaf Node(Tree) *)&lt;br /&gt;      BEGIN&lt;br /&gt;        New (Tree);&lt;br /&gt;        Tree^.Left  := NIL;&lt;br /&gt;        Tree^.Right := NIL;&lt;br /&gt;        Tree^.Info  := Element&lt;br /&gt;      END (* IF Tree = NIL *)&lt;br /&gt;&lt;br /&gt;    ELSE  (* General Case: InsertElement into correct subtree *)&lt;br /&gt;      IF Element.Key &lt; Tree^.Info.Key&lt;br /&gt;        THEN InsertElement (Tree^.Left, Element)&lt;br /&gt;        ELSE InsertElement (Tree^.Right, Element)&lt;br /&gt;&lt;br /&gt;END;  (* InsertElement *)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;(**********************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE DeleteElement&lt;br /&gt;  (VAR Tree : TreeType;&lt;br /&gt;   KeyValue : KeyType);&lt;br /&gt;&lt;br /&gt;  (* Deletes the element containing KeyValue from the binary *)&lt;br /&gt;  (* search tree pointed to by Tree. Assumes that this key   *)&lt;br /&gt;  (* value is known to exist in the tree.                    *)&lt;br /&gt;&lt;br /&gt;VAR&lt;br /&gt;  NodePtr   : TreePtrType; (* pointer to node to be deleted    *)&lt;br /&gt;  ParentPtr : TreePtrType; (* pointer to parent of delete node *)&lt;br /&gt;&lt;br /&gt;(********************* Nested Procedures ***********************)&lt;br /&gt;&lt;br /&gt;PROCEDURE FindAndRemoveMax&lt;br /&gt;  (VAR Tree   : TreePtrType;&lt;br /&gt;   VAR MaxPtr : TreePtrType);&lt;br /&gt;&lt;br /&gt;BEGIN (* FindAndRemoveMax *)&lt;br /&gt;&lt;br /&gt;  IF Tree^.Right = NIL&lt;br /&gt;    THEN (* Base Case: maximum found *)&lt;br /&gt;      BEGIN&lt;br /&gt;        MaxPtr := Tree;       (* return pointer to max node *)&lt;br /&gt;        Tree   := Tree^.Left  (* unlink max node from tree  *)&lt;br /&gt;      END (* Base Case *)&lt;br /&gt;&lt;br /&gt;    ELSE (* General Case: find and remove from right subtree *)&lt;br /&gt;      FindAndRemoveMax (Tree^.Right, MaxPtr)&lt;br /&gt;&lt;br /&gt;END;  (* FindAndRemoveMax *)&lt;br /&gt;&lt;br /&gt;(*************************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE DeleteNode&lt;br /&gt;  (VAR NodePtr : TreePtrType);&lt;br /&gt;&lt;br /&gt;  (* Deletes the node pointed to by NodePtr from the binary *)&lt;br /&gt;  (* search tree. NodePtr is a real pointer from the parent *)&lt;br /&gt;  (* node in the tree, not an external pointer.             *)&lt;br /&gt;&lt;br /&gt;VAR&lt;br /&gt;  TempPtr : TreePtrType;  (* node to delete *)&lt;br /&gt;&lt;br /&gt;BEGIN  (* DeleteNode *)&lt;br /&gt;&lt;br /&gt;  (* Save the original pointer for freeing the node. *)&lt;br /&gt;  TempPtr := NodePtr;&lt;br /&gt;&lt;br /&gt;  (* Case of no children or one child: *)&lt;br /&gt;  IF NodePtr^.Right = NIL&lt;br /&gt;    THEN NodePtr := NodePtr^.Left&lt;br /&gt;&lt;br /&gt;    ELSE (* There is at least one child. *)&lt;br /&gt;      IF NodePtr^.Left = NIL&lt;br /&gt;        THEN (* There is one child. *)&lt;br /&gt;          NodePtr := NodePtr^.Right&lt;br /&gt;&lt;br /&gt;        ELSE (* There are two children. *)&lt;br /&gt;          BEGIN&lt;br /&gt;            (* Find and remove the replacement value from *)&lt;br /&gt;            (* Node(NodePtr)'s left subtree.              *)&lt;br /&gt;            FindAndRemoveMax (NodePtr^.Left, TempPtr);&lt;br /&gt;&lt;br /&gt;            (* Replace the delete element. *)&lt;br /&gt;            NodePtr^.Info := TempPtr^.Info&lt;br /&gt;&lt;br /&gt;        END; (* There are two children. *)&lt;br /&gt;&lt;br /&gt;  (* Free the unneeded node. *)&lt;br /&gt;  Dispose (TempPtr)&lt;br /&gt;&lt;br /&gt;END;  (* DeleteNode *)&lt;br /&gt;(*****************************************************************)&lt;br /&gt;&lt;br /&gt;BEGIN (* DeleteElement *)&lt;br /&gt;&lt;br /&gt;  (* Find node containing KeyValue. *)&lt;br /&gt;  FindNode (Tree, KeyValue, NodePtr, ParentPtr);&lt;br /&gt;&lt;br /&gt;  (* Delete node pointed to by NodePtr. ParentPtr points  *)&lt;br /&gt;  (* to the parent node, or is NIL if deleting root node. *)&lt;br /&gt;  IF NodePtr = Tree&lt;br /&gt;    THEN (* Delete the root node. *)&lt;br /&gt;      DeleteNode (Tree)&lt;br /&gt;    ELSE&lt;br /&gt;      IF ParentPtr^.Left = NodePtr&lt;br /&gt;        THEN (* Delete the left child node. *)&lt;br /&gt;          DeleteNode (ParentPtr^.Left)&lt;br /&gt;        ELSE (* Delete the right child node. *)&lt;br /&gt;          DeleteNode (ParentPtr^.Right)&lt;br /&gt;&lt;br /&gt;END;  (* DeleteElement *)&lt;br /&gt;&lt;br /&gt;(***********************************************************)&lt;br /&gt;&lt;br /&gt;{The following procedure has been commented out:&lt;br /&gt;PROCEDURE DeleteElement&lt;br /&gt;  (VAR Tree : TreeType;&lt;br /&gt;   KeyValue : KeyType);&lt;br /&gt;&lt;br /&gt;  (* Recursive version of DeleteElement operation. *)&lt;br /&gt;&lt;br /&gt;BEGIN (* DeleteElement *)&lt;br /&gt;&lt;br /&gt;  IF KeyValue = Tree^.Info.Key&lt;br /&gt;    THEN (* Base Case : delete this node *)&lt;br /&gt;      DeleteNode (Tree)&lt;br /&gt;&lt;br /&gt;    ELSE&lt;br /&gt;      IF KeyValue &lt; Tree^.Info.Key&lt;br /&gt;        THEN (* General Case 1: delete node from left subtree *)&lt;br /&gt;          DeleteElement (Tree^.Left, KeyValue)&lt;br /&gt;        ELSE (* General Case 2: delete node from right subtree *)&lt;br /&gt;          DeleteElement (Tree^.Right, KeyValue)&lt;br /&gt;&lt;br /&gt;END;  (* DeleteElement *)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;(****************************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE PrintTree&lt;br /&gt;  (Tree           : TreeType;&lt;br /&gt;   TraversalOrder : TraversalType);&lt;br /&gt;&lt;br /&gt;  (* Print all the elements in the tree, in the order *)&lt;br /&gt;  (* specified by TraversalOrder.                     *)&lt;br /&gt;&lt;br /&gt;(********************** Nested Procedures ************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE PrintNode&lt;br /&gt;  (Element : TreeElementType);&lt;br /&gt;&lt;br /&gt;BEGIN (* PrintNode *)&lt;br /&gt;&lt;br /&gt;  Writeln (Element.Key);&lt;br /&gt;  (* other statements as needed *)&lt;br /&gt;&lt;br /&gt;END;  (* PrintNode *)&lt;br /&gt;&lt;br /&gt;(*********************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE PrintInorder&lt;br /&gt;  (Tree : TreeType);&lt;br /&gt;&lt;br /&gt;  (* Prints out the elements in a binary search tree in *)&lt;br /&gt;  (* order from smallest to largest. This procedure is  *)&lt;br /&gt;  (* a recursive solution.                              *)&lt;br /&gt;&lt;br /&gt;BEGIN  (* PrintInorder *)&lt;br /&gt;&lt;br /&gt;  (* Base Case: If Tree is NIL, do nothing. *)&lt;br /&gt;  IF Tree &lt;&gt;NIL&lt;br /&gt;    THEN&lt;br /&gt;&lt;br /&gt;      BEGIN (* General Case *)&lt;br /&gt;&lt;br /&gt;        (* Traverse left subtree to print smaller values. *)&lt;br /&gt;        PrintInorder(Tree^.Left);&lt;br /&gt;&lt;br /&gt;        (* Print the information in this node. *)&lt;br /&gt;        PrintNode(Tree^.Info);&lt;br /&gt;        (* Traverse right subtree to print larger values. *)&lt;br /&gt;        PrintInorder(Tree^.Right)&lt;br /&gt;&lt;br /&gt;      END (* General Case *)&lt;br /&gt;END; (* PrintInorder *)&lt;br /&gt;&lt;br /&gt;(***************************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE PrintPreorder&lt;br /&gt;  (Tree : TreeType);&lt;br /&gt;&lt;br /&gt;  (* Print out the elements in a binary search tree in *)&lt;br /&gt;  (* preorder. This procedure is a recursive solution. *)&lt;br /&gt;&lt;br /&gt;BEGIN (* PrintPreorder *)&lt;br /&gt;&lt;br /&gt;  (* Base Case: IF Tree is NIL, do nothing. *)&lt;br /&gt;  IF Tree &lt;&gt; NIL&lt;br /&gt;    THEN (* General Case *)&lt;br /&gt;      BEGIN&lt;br /&gt;&lt;br /&gt;        (* Print the value of this node. *)&lt;br /&gt;        PrintNode(Tree^.Info);&lt;br /&gt;&lt;br /&gt;        (* Traverse the left subtree in preorder. *)&lt;br /&gt;        PrintPreorder(Tree^.Left);&lt;br /&gt;&lt;br /&gt;        (* Traverse the left subtree in preorder. *)&lt;br /&gt;        PrintPreorder(Tree^.Right)&lt;br /&gt;&lt;br /&gt;      END  (* General Case *)&lt;br /&gt;END; (* PrintPreorder *)&lt;br /&gt;&lt;br /&gt;(***********************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE PrintPostorder&lt;br /&gt;  (Tree : TreeType);&lt;br /&gt;&lt;br /&gt;  (* Prints out the elements in a binary search tree in *)&lt;br /&gt;  (* postorder. This procedure is a recursive solution. *)&lt;br /&gt;&lt;br /&gt;BEGIN (* PrintPostorder *)&lt;br /&gt;&lt;br /&gt;  (* Base Case: If Tree is NIL, do nothing. *)&lt;br /&gt;  IF Tree &lt;&gt; NIL&lt;br /&gt;    THEN (* General Case *)&lt;br /&gt;      BEGIN&lt;br /&gt;&lt;br /&gt;        (* Traverse the left subtree in postorder. *)&lt;br /&gt;        PrintPostorder(Tree^.Left);&lt;br /&gt;&lt;br /&gt;        (* Traverse the right subtree in postorder. *)&lt;br /&gt;        PrintPostorder(Tree^.Right);&lt;br /&gt;&lt;br /&gt;        (* Print the value of this node. *)&lt;br /&gt;        PrintNode(Tree^.Info)&lt;br /&gt;&lt;br /&gt;      END (* General Case *)&lt;br /&gt;END; (* PrintPostorder *)&lt;br /&gt;(********************************************************)&lt;br /&gt;&lt;br /&gt;BEGIN (* PrintTree *)&lt;br /&gt;&lt;br /&gt;  (* Call internal print procedure according to TraversalOrder. *)&lt;br /&gt;  CASE TraversalOrder OF&lt;br /&gt;    Preorder  : PrintPreorder  (Tree);&lt;br /&gt;    Inorder   : PrintInorder   (Tree);&lt;br /&gt;    Postorder : PrintPostorder (Tree)&lt;br /&gt;  END (* CASE *)&lt;br /&gt;&lt;br /&gt;END;  (* PrintTree *)&lt;br /&gt;&lt;br /&gt;(***********************************************************)&lt;br /&gt;&lt;br /&gt;PROCEDURE DestroyTree&lt;br /&gt; (VAR Tree : TreeType);&lt;br /&gt;&lt;br /&gt;  (* Removes all the elements from the binary search tree *)&lt;br /&gt;  (* rooted at Tree, leaving the tree empty.              *)&lt;br /&gt;&lt;br /&gt;BEGIN (* DestroyTree *)&lt;br /&gt;&lt;br /&gt;  (* Base Case: If Tree is NIL, do nothing. *)&lt;br /&gt;  IF Tree &lt;&gt; NIL&lt;br /&gt;    THEN (* General Case *)&lt;br /&gt;      BEGIN&lt;br /&gt;&lt;br /&gt;        (* Traverse the left subtree in postorder. *)&lt;br /&gt;        DestroyTree (Tree^.Left);&lt;br /&gt;&lt;br /&gt;        (* Traverse the right subtree in postorder. *)&lt;br /&gt;        DestroyTree (Tree^.Right);&lt;br /&gt;&lt;br /&gt;        (* Delete this leaf node from the tree. *)&lt;br /&gt;        Dispose (Tree);&lt;br /&gt;&lt;br /&gt;      END (* General Case *)&lt;br /&gt;END; (* DestroyTree *)&lt;br /&gt;&lt;br /&gt;(***********************************************************)</description></item><item><title>Insertion Sort</title><link>http://pascalprog.blogspot.com/2008/06/insertion-sort.html</link><category>Insertion Sort</category><author>noreply@blogger.com (dazchild)</author><pubDate>Mon, 2 Jun 2008 02:05:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-8828072532106810847</guid><description>program insertion(input,output);&lt;br /&gt;  const&lt;br /&gt;    MAX = 10;&lt;br /&gt;  var&lt;br /&gt;    a  : array[1..MAX] of integer;&lt;br /&gt;    i, n : integer;&lt;br /&gt;&lt;br /&gt;  procedure insertion_sort;&lt;br /&gt;    var&lt;br /&gt;      i, pos : integer;&lt;br /&gt;      value : integer;&lt;br /&gt;      done : boolean;&lt;br /&gt;    begin&lt;br /&gt;      for i := 2 to n do&lt;br /&gt; begin&lt;br /&gt;&lt;br /&gt;   value := a[i];&lt;br /&gt;   pos := i;&lt;br /&gt;   done := false;&lt;br /&gt;   while not done do&lt;br /&gt;     begin&lt;br /&gt;       if pos &lt;= 1 then&lt;br /&gt;  done := true&lt;br /&gt;       else if value &gt;= a[pos-1] then&lt;br /&gt;  done := true&lt;br /&gt;       else&lt;br /&gt;  begin&lt;br /&gt;           a[pos] := a[pos-1];&lt;br /&gt;           pos := pos-1&lt;br /&gt;                end&lt;br /&gt;     end; {while}&lt;br /&gt;&lt;br /&gt;   a[pos] := value;&lt;br /&gt;&lt;br /&gt; end {for}&lt;br /&gt;    end;&lt;br /&gt;&lt;br /&gt;  begin { main }&lt;br /&gt;    writeln('How many number would you like to sort (max=',MAX:2,') ?');&lt;br /&gt;    readln(n);&lt;br /&gt;&lt;br /&gt;    writeln('Enter in ',n:1,' numbers:');&lt;br /&gt;    for i := 1 to n do&lt;br /&gt;      read(a[i]);&lt;br /&gt;&lt;br /&gt;    insertion_sort;&lt;br /&gt;&lt;br /&gt;    for i := 1 to n do&lt;br /&gt;      write(a[i]:1,' ');&lt;br /&gt;    writeln&lt;br /&gt;  end.</description></item><item><title>Heap sort algorithm</title><link>http://pascalprog.blogspot.com/2008/06/heap-sort-algorithm.html</link><category>Heap Sort</category><author>noreply@blogger.com (dazchild)</author><pubDate>Mon, 2 Jun 2008 02:02:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-6788402890738772824</guid><description>(** Heap sort algorithm.&lt;br /&gt;  *&lt;br /&gt;  * Author: Paulo Roma&lt;br /&gt;  * Date: 22/04/2008.&lt;br /&gt;  * http://en.wikipedia.org/wiki/Heapsort&lt;br /&gt;  * http://www2.hawaii.edu/~copley/665/HSApplet.html&lt;br /&gt; *)&lt;br /&gt;&lt;br /&gt;program Heap_Sort;&lt;br /&gt;&lt;br /&gt;type SArray = array of integer;&lt;br /&gt;var Asize: integer;&lt;br /&gt;var A: SArray;&lt;br /&gt;var i: integer;&lt;br /&gt;&lt;br /&gt;(** swap.&lt;br /&gt; *&lt;br /&gt; *  Swaps two given values.&lt;br /&gt; *&lt;br /&gt; *      @param a,b values to be swaped.&lt;br /&gt; *)&lt;br /&gt;&lt;br /&gt;procedure swap ( var a, b: integer );&lt;br /&gt;var temp: integer;&lt;br /&gt;begin&lt;br /&gt;  temp := a;&lt;br /&gt;  a := b;&lt;br /&gt;  b := temp;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;(** siftDown.&lt;br /&gt; *&lt;br /&gt; *  Sifts downward to establish the heap property.&lt;br /&gt; *&lt;br /&gt; *      @param A array.&lt;br /&gt; *      @param start heap root.&lt;br /&gt; *      @param end_ represents the limit of how far down the heap to sift.&lt;br /&gt; *)&lt;br /&gt;&lt;br /&gt;procedure siftDown ( var A: SArray; start, end_: integer );&lt;br /&gt;var root, child: integer;&lt;br /&gt;begin&lt;br /&gt;     root := start;&lt;br /&gt;&lt;br /&gt;     // While the root has at least one child&lt;br /&gt;     while ( root * 2 + 1 &lt;= end_ ) do begin  &lt;br /&gt;         child := root * 2 + 1;                // left child&lt;br /&gt;         // If the child has a sibling and&lt;br /&gt;         // the child's value is less than its sibling's&lt;br /&gt;         if ( child &lt; end_ ) and ( A[child] &lt; A[child + 1] ) then&lt;br /&gt;             child := child + 1;               // point to the right child instead&lt;br /&gt;         if ( A[root] &lt; A[child] ) then begin  // out of max-heap order&lt;br /&gt;             swap ( A[root], A[child] );&lt;br /&gt;             root := child;                    // repeat to continue sifting down the child&lt;br /&gt;         end&lt;br /&gt;         else&lt;br /&gt;             break;&lt;br /&gt;     end;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;(** heapify.&lt;br /&gt; *&lt;br /&gt; *  Builds a heap from the bottom up.&lt;br /&gt; *&lt;br /&gt; *  The heapify function can be thought of as building a&lt;br /&gt; *  heap from the bottom up, successively sifting downward&lt;br /&gt; *  to establish the heap property.&lt;br /&gt; *&lt;br /&gt; *      @param A array.&lt;br /&gt; *      @param count number of elements in A.&lt;br /&gt; *)&lt;br /&gt;&lt;br /&gt;procedure heapify ( var A: SArray; count: integer );&lt;br /&gt;var start: integer;&lt;br /&gt;begin&lt;br /&gt;     // start is assigned the index in A of the last parent node&lt;br /&gt;     start := (count - 1) div 2;&lt;br /&gt;    &lt;br /&gt;     while ( start &gt;= 0 ) do begin&lt;br /&gt;         // sift down the node at start index to the proper place,&lt;br /&gt;         // such that all nodes below the start index are in heap order&lt;br /&gt;         siftDown (A, start, count-1);&lt;br /&gt;         start := start - 1;&lt;br /&gt;        // after sifting down the root all nodes/elements are in heap order&lt;br /&gt;     end;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;(** heapSort.&lt;br /&gt; *&lt;br /&gt; *  Sorts A=(A0, A1, ..., An) into nondecreasing order of keys.&lt;br /&gt; *  This algorithm has a worst case computational time of O(n log n).&lt;br /&gt; *  Not stable.&lt;br /&gt; *&lt;br /&gt; *  Heapsort primarily competes with quicksort,&lt;br /&gt; *  another very efficient, general purpose, and&lt;br /&gt; *  nearly-in-place, comparison-based sort algorithm.&lt;br /&gt; *&lt;br /&gt; *  Heapsort inserts the input list elements into a heap data structure.&lt;br /&gt; *  The largest value (in a max-heap) or the smallest value&lt;br /&gt; *  (in a min-heap) are extracted until none remain,&lt;br /&gt; *  the values being extracted in sorted order.&lt;br /&gt; *  The heap's invariant is preserved after each&lt;br /&gt; *  extraction, so the only cost is that of extraction.&lt;br /&gt; *&lt;br /&gt; *  During extraction, the only space required is that needed to store&lt;br /&gt; *  the heap. In order to achieve constant space overhead, the heap&lt;br /&gt; *  is stored in the part of the input array that has not yet been sorted.&lt;br /&gt; *  (The structure of this heap is described at Binary heap:&lt;br /&gt; *   Heap implementation.)&lt;br /&gt; *&lt;br /&gt; *  Heapsort uses two heap operations: insertion and root deletion.&lt;br /&gt; *  Each extraction places an element in the last empty location of&lt;br /&gt; *  the array. The remaining prefix of the array stores the&lt;br /&gt; *  unsorted elements.&lt;br /&gt; *&lt;br /&gt; *      @param A array to be sorted.&lt;br /&gt; *      @param n number of elements to be sorted.&lt;br /&gt; *)&lt;br /&gt;&lt;br /&gt;procedure heapSort( var A: SArray; n: integer );&lt;br /&gt;var end_: integer;&lt;br /&gt;begin&lt;br /&gt;     // first place A in max-heap order&lt;br /&gt;     heapify ( A, n );&lt;br /&gt;&lt;br /&gt;     end_ := n - 1;&lt;br /&gt;     while ( end_ &gt; 0 ) do begin&lt;br /&gt;         // swap the root (maximum value) of the heap&lt;br /&gt;         // with the last element of the heap&lt;br /&gt;         swap( A[end_], A[0]);&lt;br /&gt;         // decrease the size of the heap by one,&lt;br /&gt;         // so that the previous max value&lt;br /&gt;         // will stay in its proper placement&lt;br /&gt;         end_ := end_ - 1;&lt;br /&gt;         // put the heap back in max-heap order&lt;br /&gt;         siftDown (A, 0, end_);&lt;br /&gt;     end;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;  write ( 'Enter number of elements: ' );&lt;br /&gt;  read ( Asize );&lt;br /&gt;  // alocate an array from 0 to Asize-1&lt;br /&gt;  // the array index is always zero-based&lt;br /&gt;  SetLength ( A, Asize );&lt;br /&gt;  // generate the seed&lt;br /&gt;  randomize;&lt;br /&gt;  // fill A with random numbers in the range [0..99]&lt;br /&gt;  for i := 0 to Asize-1 do&lt;br /&gt;    A[i] := random (100);&lt;br /&gt;&lt;br /&gt;  // print original array&lt;br /&gt;  for i := 0 to Asize-1 do begin&lt;br /&gt;    write (A[i]); write (' ');&lt;br /&gt;  end;&lt;br /&gt;  writeln;&lt;br /&gt;&lt;br /&gt;  // sort&lt;br /&gt;  heapSort ( A, Asize );&lt;br /&gt;&lt;br /&gt;  // print sorted array&lt;br /&gt;  for i := 0 to Asize-1 do begin&lt;br /&gt;    write (A[i]); write (' ');&lt;br /&gt;  end;&lt;br /&gt;  writeln;&lt;br /&gt;end.</description></item><item><title>Tower Of Hanoi</title><link>http://pascalprog.blogspot.com/2008/06/tower-of-hanoi.html</link><category>hanoi</category><category>Tower Of Hanoi</category><author>noreply@blogger.com (dazchild)</author><pubDate>Mon, 2 Jun 2008 02:01:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-143919485956608449</guid><description>(* &lt;br /&gt;   http://en.wikipedia.org/wiki/Tower_of_Hanoi&lt;br /&gt;   http://www.cut-the-knot.org/recurrence/hanoi.shtml&lt;br /&gt;   Recurrence: T(h) = 2T(h-1) + 1 = 2**h - 1 --&gt; O(2**h)&lt;br /&gt;*)&lt;br /&gt;&lt;br /&gt;program Hanoi_Tower;&lt;br /&gt;// number of disks&lt;br /&gt;var nd: integer;&lt;br /&gt;&lt;br /&gt;(** Hanoi. &lt;br /&gt; *&lt;br /&gt; *  A game invented by the French mathematician Edouard Lucas in 1883.&lt;br /&gt; *&lt;br /&gt; *  1. Move the top N-1 disks from Src to Aux (using Dst as an intermediary peg)&lt;br /&gt; *  2. Move the bottom disk from Src to Dst&lt;br /&gt; *  3. Move N-1 disks from Aux to Dst (using Src as an intermediary peg) &lt;br /&gt; *&lt;br /&gt; *     @param n    number of disks.&lt;br /&gt; *     @param from source peg.&lt;br /&gt; *     @param to_  destination peg.&lt;br /&gt; *     @param by   intermediary peg.&lt;br /&gt; *)&lt;br /&gt;procedure Hanoi(n: integer; from, to_, by: char);&lt;br /&gt;begin&lt;br /&gt;    if (n=1) then&lt;br /&gt;        writeln('Move the plate from ', from, ' to ', to_)&lt;br /&gt;    else begin&lt;br /&gt;        Hanoi(n-1, from, by,  to_);&lt;br /&gt;        Hanoi(1,   from, to_, by);&lt;br /&gt;        Hanoi(n-1, by,   to_, from);&lt;br /&gt;    end;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;  write ( 'Enter number of disks: ' );&lt;br /&gt;  readln ( nd );&lt;br /&gt;  Hanoi (nd,'A','B','C')&lt;br /&gt;end.</description></item><item><title>Merge Sort</title><link>http://pascalprog.blogspot.com/2008/06/merge-sort.html</link><category>Merge Sort</category><author>noreply@blogger.com (dazchild)</author><pubDate>Mon, 2 Jun 2008 02:00:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-4611757089943957918</guid><description>{confronti tra algortitmi}
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;type INTARRAY = array[1..100000] of integer;
&lt;br /&gt;
&lt;br /&gt;procedure gen_array(var A:INTARRAY; N:integer);
&lt;br /&gt;  var  i:integer;
&lt;br /&gt;  begin
&lt;br /&gt;    for i:=1 to N do  A[i]:=Random(10*N);
&lt;br /&gt;  end;
&lt;br /&gt;
&lt;br /&gt;{copia l'array X in Y}
&lt;br /&gt;procedure copy_array(var X, Y:INTARRAY; n:integer);
&lt;br /&gt;  var i:integer;
&lt;br /&gt;  begin
&lt;br /&gt;  for i := 0 to N do Y[i] := X[i];
&lt;br /&gt;  end;
&lt;br /&gt;
&lt;br /&gt;function min(a,b:integer):integer;
&lt;br /&gt;  begin if  a&lt;b then min := a
&lt;br /&gt;                else min := b;
&lt;br /&gt;  end;
&lt;br /&gt;
&lt;br /&gt;procedure print_array(var A:INTARRAY; N:integer);
&lt;br /&gt;  var  i:integer;
&lt;br /&gt;  begin
&lt;br /&gt;    for i:=1 to min(n, 100) do
&lt;br /&gt;       begin
&lt;br /&gt;       write(A[i]:6);
&lt;br /&gt;       if ((i mod 10)= 0)  then writeln;
&lt;br /&gt;       end;
&lt;br /&gt;  if (n&gt;100) then writeln('......'); //writeln('array troppo lungo da scrivere');
&lt;br /&gt;  end;
&lt;br /&gt;
&lt;br /&gt;procedure InsSort(var A: INTARRAY; N: integer);
&lt;br /&gt;var i, j, t, indM: integer;
&lt;br /&gt;begin {Insertion Sort }
&lt;br /&gt;for i := 1 to N-1 do
&lt;br /&gt;   begin
&lt;br /&gt;   indM:=i;
&lt;br /&gt;   for j:=i+1 to N do
&lt;br /&gt;      if A[j]&lt;A[indM] then indM:=j;
&lt;br /&gt;   t:= A[i];
&lt;br /&gt;   A[i]:=A[indM];
&lt;br /&gt;   A[indM] := t;
&lt;br /&gt;   end;
&lt;br /&gt; end;
&lt;br /&gt;
&lt;br /&gt;procedure Merge (var A: INTARRAY; p, q, r: integer);
&lt;br /&gt;var i, j, k: integer;
&lt;br /&gt;var B: INTARRAY;
&lt;br /&gt;begin { Merge }
&lt;br /&gt;  i := p;
&lt;br /&gt;  j := q + 1;
&lt;br /&gt;  k := p;
&lt;br /&gt;  while ((i &lt;= q) and (j &lt;= r)) do
&lt;br /&gt;    begin
&lt;br /&gt;      if (A[i] &lt; A[j])
&lt;br /&gt;         then begin
&lt;br /&gt;                B[k] := A[i];
&lt;br /&gt;                i := i + 1;
&lt;br /&gt;              end
&lt;br /&gt;         else begin
&lt;br /&gt;                B[k] := A[j];
&lt;br /&gt;                j := j + 1;
&lt;br /&gt;              end;
&lt;br /&gt;      k := k + 1;
&lt;br /&gt;    end;
&lt;br /&gt;    while (i &lt;= q) do
&lt;br /&gt;      begin
&lt;br /&gt;        B[k] := A[i];
&lt;br /&gt;        k := k + 1;
&lt;br /&gt;        i := i + 1;
&lt;br /&gt;      end;
&lt;br /&gt;    while (j &lt;= r) do
&lt;br /&gt;      begin
&lt;br /&gt;        B[k] := A[j];
&lt;br /&gt;        k := k + 1;
&lt;br /&gt;        j := j + 1;
&lt;br /&gt;      end;
&lt;br /&gt;    for k := p to r do A[k] := B[k];
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;procedure MergeSort (var A: INTARRAY; p, r: integer);
&lt;br /&gt;var q: integer;
&lt;br /&gt;begin { MergeSort }
&lt;br /&gt;  if (p &lt; r) then
&lt;br /&gt;               begin
&lt;br /&gt;                 q := (p + r) div 2;
&lt;br /&gt;                 MergeSort (A, p, q);
&lt;br /&gt;                 MergeSort (A, q + 1, r);
&lt;br /&gt;                 Merge (A, p, q, r);
&lt;br /&gt;               end;
&lt;br /&gt; end;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;var data: INTARRAY;
&lt;br /&gt;var A: INTARRAY;
&lt;br /&gt;var i, j, key:integer;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;// Programma principale
&lt;br /&gt;var N:integer;
&lt;br /&gt;begin
&lt;br /&gt;write('numero elementi: ');
&lt;br /&gt;readln(N);
&lt;br /&gt;gen_array(data, N);
&lt;br /&gt;
&lt;br /&gt;copy_array(data, A, N);
&lt;br /&gt;
&lt;br /&gt;writeln('array in input: ');
&lt;br /&gt;print_array(data, N);
&lt;br /&gt;writeln('pronto ad ordinare con isertion sort: ');
&lt;br /&gt;readln;
&lt;br /&gt;InsSort(data, N);
&lt;br /&gt;writeln('array dopo ordinamento:');
&lt;br /&gt;print_array(data, N);
&lt;br /&gt;
&lt;br /&gt;copy_array(A, data, N);
&lt;br /&gt;writeln('pronto ad ordinare  con merge sort: ');
&lt;br /&gt;readln;
&lt;br /&gt;MergeSort(data, 1, N);
&lt;br /&gt;writeln('array dopo ordinamento:');
&lt;br /&gt;print_array(data, N);
&lt;br /&gt;writeln('programma finito');
&lt;br /&gt;readln;
&lt;br /&gt;end.
&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Bubble Sort</title><link>http://pascalprog.blogspot.com/2008/06/bubble-sort.html</link><category>Bubble SOrt</category><author>noreply@blogger.com (dazchild)</author><pubDate>Mon, 2 Jun 2008 01:59:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-8629797388391583477</guid><description>(** Bubble sort algorithm.&lt;br /&gt;  *&lt;br /&gt;  * Author: Paulo Roma&lt;br /&gt;  * Date: 21/04/2008.&lt;br /&gt;  * http://en.wikipedia.org/wiki/Bubble_sort&lt;br /&gt; *)&lt;br /&gt;&lt;br /&gt;program Bubble_Sort;&lt;br /&gt;&lt;br /&gt;type SArray = array of integer;&lt;br /&gt;var Asize: integer;&lt;br /&gt;var A: SArray;&lt;br /&gt;var i: integer;&lt;br /&gt;&lt;br /&gt;(** bubbleSort.&lt;br /&gt; *&lt;br /&gt; *  Sorts A=(A0, A1, ..., An) into nondecreasing order of keys.&lt;br /&gt; *  This algorithm has a worst case computational time of O(n**2).&lt;br /&gt; *  Stable.&lt;br /&gt; *&lt;br /&gt; *  Bubble sort is a straightforward and simplistic method of sorting&lt;br /&gt; *  data that is used in computer science education.&lt;br /&gt; *  The algorithm starts at the beginning of the data set.&lt;br /&gt; *  It compares the first two elements, and if the first is greater&lt;br /&gt; *  than the second, it swaps them. It continues doing this&lt;br /&gt; *  for each pair of adjacent elements to the end of the data set.&lt;br /&gt; *  It then starts again with the first two elements, repeating until&lt;br /&gt; *  no swaps have occurred on the last pass. While simple, this algorithm&lt;br /&gt; *  is highly inefficient and is rarely used except in education.&lt;br /&gt; *  A slightly better variant, cocktail sort, works by inverting the&lt;br /&gt; *  ordering criteria and the pass direction on alternating passes.&lt;br /&gt; *  Its average case and worst case are both O(n**2).&lt;br /&gt; *&lt;br /&gt; *  Large elements at the beginning of the list do not pose a problem,&lt;br /&gt; *  as they are quickly swapped. Small elements towards the end,&lt;br /&gt; *  however, move to the beginning extremely slowly.&lt;br /&gt; *  This has led to these types of elements being named rabbits and&lt;br /&gt; *  turtles, respectively.&lt;br /&gt; *&lt;br /&gt; *      @param A array to be sorted.&lt;br /&gt; *      @param n number of elements to be sorted.&lt;br /&gt; *)&lt;br /&gt;&lt;br /&gt;procedure bubbleSort( var A: SArray; n: integer );&lt;br /&gt;var swapped: boolean;&lt;br /&gt;var i, temp: integer;&lt;br /&gt;begin&lt;br /&gt;  repeat&lt;br /&gt;    swapped := false;&lt;br /&gt;    n := n - 1;&lt;br /&gt;    for i := 0 to n-1 do begin&lt;br /&gt;      if ( A[i] &gt; A[i+1] ) then begin&lt;br /&gt;        // swap&lt;br /&gt;        temp    := A[i];&lt;br /&gt;        A[i]    := A[i+1];&lt;br /&gt;        A[i+1]  := temp;&lt;br /&gt;        swapped := true;&lt;br /&gt;        // every time one pass of this loop is completed,&lt;br /&gt;        // the largest element has been moved to the end&lt;br /&gt;        // of the array&lt;br /&gt;      end&lt;br /&gt;    end;&lt;br /&gt;  until not swapped;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;  write ( 'Enter number of elements: ' );&lt;br /&gt;  read ( Asize );&lt;br /&gt;  // alocate an array from 0 to Asize-1&lt;br /&gt;  // the array index is always zero-based&lt;br /&gt;  SetLength ( A, Asize );&lt;br /&gt;  // generate the seed&lt;br /&gt;  randomize;&lt;br /&gt;  // fill A with random numbers in the range [0..99]&lt;br /&gt;  for i := 0 to Asize-1 do&lt;br /&gt;    A[i] := random (100);&lt;br /&gt;&lt;br /&gt;  // print original array&lt;br /&gt;  for i := 0 to Asize-1 do begin&lt;br /&gt;    write (A[i]); write (' ');&lt;br /&gt;  end;&lt;br /&gt;  writeln;&lt;br /&gt;&lt;br /&gt;  // sort&lt;br /&gt;  bubbleSort ( A, Asize );&lt;br /&gt;&lt;br /&gt;  // print sorted array&lt;br /&gt;  for i := 0 to Asize-1 do begin&lt;br /&gt;    write (A[i]); write (' ');&lt;br /&gt;  end;&lt;br /&gt;  writeln;&lt;br /&gt;end.</description></item><item><title>Program TLSort (4 type Sorting and The Time[Effectivity])</title><link>http://pascalprog.blogspot.com/2008/06/program-tlsort-4-type-sorting-and.html</link><category>Bubble</category><category>Insertion</category><category>Merge</category><category>Quick</category><category>Selection</category><category>Sort</category><category>Time</category><author>noreply@blogger.com (dazchild)</author><pubDate>Mon, 2 Jun 2008 01:40:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-6485276744170148288</guid><description>&lt;pre&gt;
&lt;br /&gt;program TLSort;
&lt;br /&gt;Uses Dos,crt;
&lt;br /&gt;Const maks   = 20000; {dpt ditambahkan selama tidak out of memory}
&lt;br /&gt;Type  indeks = 1..maks;{Indeks Data}
&lt;br /&gt;	  Data   = array[indeks] of integer;
&lt;br /&gt;
&lt;br /&gt;var Banyak, i : integer;
&lt;br /&gt;    A,B       : Data; {Data A=data Awal, Data B:Data Setelah Pengurutan}
&lt;br /&gt;    jam1,mnt1,dtk1,mdtk1 : word; {waktu awal pengurutan}
&lt;br /&gt;    jam2,mnt2,dtk2,mdtk2 : word; {waktu akhir pengurutan}
&lt;br /&gt;
&lt;br /&gt;Procedure Identitas; {Prosedur identitas program ini}
&lt;br /&gt;begin
&lt;br /&gt;   GotoXy(20,5); Writeln('Muchamad Dachlan Zaim (M0507028)');
&lt;br /&gt;   GotoXy(20,6); Writeln('   Program Uthek2 Pointer v.1   ');
&lt;br /&gt;   GotoXy(20,7); Writeln('      Tanggal 20 Maret 2008     ');  
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;Procedure BuatData(var X:Data; n:integer);
&lt;br /&gt;begin    {Prosedur untuk membuat data secara random}
&lt;br /&gt;   randomize;
&lt;br /&gt;   for i := 1 to n do X[i] := random(10000);
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;Procedure CetakData(X:data);
&lt;br /&gt;begin  {Prosedur untuk mencetak data bilangan}
&lt;br /&gt;   for i := 1 to Banyak do writeln(i:10,'  ',A[i]); 
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;Procedure ulang(X:data;var Y:data; n:integer);
&lt;br /&gt;begin {prosedur untuk memindahkan data yang belum diurut(X) dengan yang sudah urut(Y)}
&lt;br /&gt;  for i:=1 to n do Y[i]:=X[i];
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;procedure bubbleSort(X:Data; var Y:data; n:integer);
&lt;br /&gt;var swap     : boolean; {Prosedur pengurutan dengan bubble sort}
&lt;br /&gt;    i, titip : integer;
&lt;br /&gt;begin
&lt;br /&gt;  repeat
&lt;br /&gt;    swap := false; 
&lt;br /&gt;    for i:=1 to n-1 do 
&lt;br /&gt;       begin
&lt;br /&gt;       if (X[i]&gt;X[i+1]) then 
&lt;br /&gt;          begin
&lt;br /&gt;          titip  := X[i];   {Pengecekan satu per satu bilangan sebelum dan sesudah}
&lt;br /&gt;          X[i]   := X[i+1]; {jika bil sebelum&gt;bil sesudah, maka bil tersebut ditukar}
&lt;br /&gt;          X[i+1] := titip;  {penempatannya}
&lt;br /&gt;          swap   := true;
&lt;br /&gt;          end
&lt;br /&gt;       end;
&lt;br /&gt;  until not(swap);
&lt;br /&gt;  Ulang(X,Y,n);
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;procedure selectionSort(X:Data; var Y:data; n: integer);
&lt;br /&gt;var i, j, min, titip: integer;
&lt;br /&gt;begin
&lt;br /&gt;  for i:=1 to n-1 do 
&lt;br /&gt;    begin
&lt;br /&gt;    min := i;
&lt;br /&gt;    for j:=i to n do 
&lt;br /&gt;       begin
&lt;br /&gt;       if (X[j]&lt;X[min]) then min := j;
&lt;br /&gt;       end;
&lt;br /&gt;    titip  := X[i];   {}
&lt;br /&gt;    X[i]   := X[min]; {}
&lt;br /&gt;    X[min] := titip;  {}
&lt;br /&gt;    end;
&lt;br /&gt;  Ulang(X,Y,n);
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;procedure insertionSort(X:Data; var Y:data; n:integer);
&lt;br /&gt;var i, j, nilai: integer; wis:boolean;
&lt;br /&gt;begin
&lt;br /&gt;  for i:=2 to n do 
&lt;br /&gt;    begin
&lt;br /&gt;    nilai := X[i];
&lt;br /&gt;    j     := i-1;
&lt;br /&gt;    wis   := false;
&lt;br /&gt;    while not(wis) do
&lt;br /&gt;	    begin
&lt;br /&gt;	      if j&lt;= 1 then wis := true
&lt;br /&gt;	      else if nilai&gt;=a[j-1] then wis := true
&lt;br /&gt;	      else begin
&lt;br /&gt;	           a[j] := a[j-1];
&lt;br /&gt;	           j    := j-1
&lt;br /&gt;               end
&lt;br /&gt;	    end;
&lt;br /&gt;    a[j] := nilai;
&lt;br /&gt;    end;
&lt;br /&gt;  ulang(X,Y,n);
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;Procedure MergeSort(X:Data; var Y:data; n:integer);
&lt;br /&gt;  procedure merge(var X:Data; p,q,r: integer);
&lt;br /&gt;  var i,j,k: integer;
&lt;br /&gt;      Y: Data;
&lt;br /&gt;  begin
&lt;br /&gt;    i := p;   k := p;   j := q+1;
&lt;br /&gt;    while ((i&lt;=q) and (j&lt;=r)) do 
&lt;br /&gt;       begin
&lt;br /&gt;       if ( X[i] &lt;= X[j] ) then 
&lt;br /&gt;            begin
&lt;br /&gt;            Y[k] := X[i];
&lt;br /&gt;            i    := i+1;
&lt;br /&gt;            end
&lt;br /&gt;       else begin
&lt;br /&gt;            Y[k] := X[j];
&lt;br /&gt;            j    := j+1
&lt;br /&gt;            end;
&lt;br /&gt;       k := k+1;
&lt;br /&gt;       end;
&lt;br /&gt;    while ( i &lt;= q ) do 
&lt;br /&gt;       begin
&lt;br /&gt;       Y[k] := X[i];
&lt;br /&gt;       k    := k+1; 
&lt;br /&gt;       i    := i+1;
&lt;br /&gt;       end;
&lt;br /&gt;    while (j&lt;=r) do 
&lt;br /&gt;       begin
&lt;br /&gt;       Y[k] := X[j];
&lt;br /&gt;       k    := k+1; 
&lt;br /&gt;       j    := j+1;
&lt;br /&gt;       end;  
&lt;br /&gt;    for i:=p to r do X[i]:=Y[i];  
&lt;br /&gt;  end; 
&lt;br /&gt;
&lt;br /&gt;  procedure merge2(var X:Data; p,r:integer);
&lt;br /&gt;  var q: integer;
&lt;br /&gt;  begin
&lt;br /&gt;     if (p&lt;r) then 
&lt;br /&gt;        begin
&lt;br /&gt;        q:=(p+r)div 2;
&lt;br /&gt;        merge2(X, p, q);
&lt;br /&gt;        merge2(X, q+1, r);
&lt;br /&gt;        merge (X, p, q, r);
&lt;br /&gt;        end;
&lt;br /&gt;  end;
&lt;br /&gt;begin
&lt;br /&gt;  Merge2(A,1,Banyak);
&lt;br /&gt;  ulang(X,Y,n);
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;Function L0(w: word):string ;
&lt;br /&gt;var s : string ;
&lt;br /&gt;begin
&lt;br /&gt;  Str(w:0,s);
&lt;br /&gt;  if w&lt;10 then s:='0' + s;
&lt;br /&gt;  L0 := s ;
&lt;br /&gt;end ;
&lt;br /&gt;
&lt;br /&gt;Procedure CetakWaktu(jamB,jamA,mntB,mntA,dtkB,dtkA,mdtkB,mdtkA:word);
&lt;br /&gt;var jamC,mntC,dtkC,mdtkC:word;
&lt;br /&gt;begin
&lt;br /&gt;  jamC:=0; mntC:=0; dtkC:=0; mdtkC:=0;
&lt;br /&gt;  writeln(L0(jamA),' : ',L0(mntA),' : ',L0(dtkA),' : ',L0(mdtkA));
&lt;br /&gt;  writeln(L0(jamB),' : ',L0(mntB),' : ',L0(dtkB),' : ',L0(mdtkB));
&lt;br /&gt;  if(mdtkB-mdtkA)&lt;0 then begin mdtkC:=mdtkB+100-mdtkA; dtkB:=dtkB-1;end
&lt;br /&gt;    else mdtkC:=mdtkB-mdtkA;
&lt;br /&gt;  if(dtkB-dtkA)&lt;0   then begin dtkC:=dtkB+60-dtkA;    mntB:=mntB-1;end
&lt;br /&gt;    else dtkC:=dtkB-dtkA; 
&lt;br /&gt;  if(mntB-mntA)&lt;0   then begin mntC:=mntB+60-mntA;    jamB:=jamB-1;end
&lt;br /&gt;    else mntC:=mntB-mntA;
&lt;br /&gt;  jamC:=jamB-jamA;  
&lt;br /&gt;  WriteLn(L0(jamC),' : ',L0(mntC),' : ',L0(dtkC),' : ',L0(mdtkC));  
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;Procedure Menu;
&lt;br /&gt;begin
&lt;br /&gt;  clrscr;
&lt;br /&gt;  identitas;
&lt;br /&gt;  write('Masukkan Banyak Bilangan yang Akan dirandom: ' ); read(Banyak);
&lt;br /&gt;  BuatData(A,Banyak);
&lt;br /&gt;  CetakData(A);  
&lt;br /&gt;  readln;
&lt;br /&gt;  getTime(jam1,mnt1,dtk1,mdtk1); BubbleSort(A,B,Banyak);  getTime(jam2,mnt2,dtk2,mdtk2);
&lt;br /&gt;  Writeln('Waktu Bubble'); 
&lt;br /&gt;  CetakWaktu(jam2,jam1,mnt2,mnt1,dtk2,dtk1,mdtk2,mdtk1);
&lt;br /&gt;  readln;
&lt;br /&gt;  getTime(jam1,mnt1,dtk1,mdtk1); InsertionSort(A,B,Banyak);  getTime(jam2,mnt2,dtk2,mdtk2);
&lt;br /&gt;  Writeln('Waktu Insertion'); 
&lt;br /&gt;  CetakWaktu(jam2,jam1,mnt2,mnt1,dtk2,dtk1,mdtk2,mdtk1);
&lt;br /&gt;  readln;
&lt;br /&gt;  getTime(jam1,mnt1,dtk1,mdtk1); SelectionSort(A,B,Banyak);  getTime(jam2,mnt2,dtk2,mdtk2);
&lt;br /&gt;  Writeln('Waktu Selection'); 
&lt;br /&gt;  CetakWaktu(jam2,jam1,mnt2,mnt1,dtk2,dtk1,mdtk2,mdtk1);
&lt;br /&gt;  readln;
&lt;br /&gt;  getTime(jam1,mnt1,dtk1,mdtk1); MergeSort(A,B,Banyak);  getTime(jam2,mnt2,dtk2,mdtk2);
&lt;br /&gt;  Writeln('Waktu Merge'); 
&lt;br /&gt;  CetakWaktu(jam2,jam1,mnt2,mnt1,dtk2,dtk1,mdtk2,mdtk1);
&lt;br /&gt;  readln;
&lt;br /&gt;  Write('Mau lihat hasil Datanya?? '); readln;
&lt;br /&gt;  
&lt;br /&gt;  CetakData(A);
&lt;br /&gt;  readln;
&lt;br /&gt;end;
&lt;br /&gt;
&lt;br /&gt;begin
&lt;br /&gt;  Menu; 
&lt;br /&gt;end.
&lt;br /&gt;
&lt;br /&gt;&lt;/pre&gt;</description></item><item><title>Program TLQueue</title><link>http://pascalprog.blogspot.com/2008/06/program-tlqueue.html</link><author>noreply@blogger.com (dazchild)</author><pubDate>Mon, 2 Jun 2008 01:38:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-4683034624778270515</guid><description>Program Queue;&lt;br /&gt;Uses Wincrt;&lt;br /&gt;Type antrian = ^node;         {Program QUEUE menggunakan Record}&lt;br /&gt;     node = Record&lt;br /&gt;             isi  : String[10];&lt;br /&gt;             next : antrian; End;&lt;br /&gt;Var dpn, blk, baru : antrian;&lt;br /&gt;   x,y            : String[10];&lt;br /&gt;   i              : integer;&lt;br /&gt;&lt;br /&gt;Function IsEmpty: boolean; {Fungsi digunakan untuk menge-cek apakah antrian kosong ato tidak}&lt;br /&gt;  Begin    {Meng-cek apakah node Depan dan Belakang Kosong atau tidak??}&lt;br /&gt;     IsEmpty := (dpn=nil) and (blk=nil);&lt;br /&gt;  End;&lt;br /&gt;      &lt;br /&gt;Procedure Cetak; {Cetak Antrian secara FIFO(First In First Out)}&lt;br /&gt;Var bantu : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     writeln; write('     Hasil Cetak Data = ');&lt;br /&gt;     If not(IsEmpty) then     {Cek dulu apakah kosong atau tidak}&lt;br /&gt;        Begin                   &lt;br /&gt;           bantu := dpn;         {Variabel bantu untuk tambahan, apabila bantu tidak kosong, maka diCETAK}&lt;br /&gt;           While bantu &lt;&gt; nil do {antrian maju dan diulangi sampai variabel bantu kosong isinya}&lt;br /&gt;              Begin&lt;br /&gt;                 write(bantu^.isi:5);&lt;br /&gt;                 bantu := bantu^.next;&lt;br /&gt;              End;&lt;br /&gt;        End&lt;br /&gt;     Else write('Antrian KOSONG, Tidak Ada Yang Bisa Dicetak !!');&lt;br /&gt;     writeln;&lt;br /&gt;     write('     =====================================================================   ');&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Procedure Buat; {Prosedur untuk membuat antrian/menambah antrian di belakang}&lt;br /&gt;Var baru : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     new(baru);&lt;br /&gt;     baru^.isi := x;&lt;br /&gt;     baru^.next := nil;&lt;br /&gt;     If IsEmpty then    {Apabila Antrian kosong maka buat baru di antrian tersebut}&lt;br /&gt;          Begin         {Jika tidak, maka buat baru setelah antrian tersebut}&lt;br /&gt;          dpn := baru;&lt;br /&gt;          blk := baru;&lt;br /&gt;          End&lt;br /&gt;     Else Begin&lt;br /&gt;          blk^.next  := baru;&lt;br /&gt;          blk        := baru;&lt;br /&gt;          End;&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Function Cari(x : String): boolean; {Fungsi pencarian data "X" di antrian}&lt;br /&gt;Var ada : boolean; bantu : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     ada   := false;&lt;br /&gt;     bantu := dpn;&lt;br /&gt;     Repeat {Pengulangan cek pada tiap node apakah "x" ada di dalamnya?? Jika tidak maka lanjut ke node selanjutnya}&lt;br /&gt;        If (bantu^.isi = x) then ada := true {sampai ada=TRUE atau tidak ada sama sekali}&lt;br /&gt;        Else bantu := bantu^.next;&lt;br /&gt;     Until ada or (bantu = nil);&lt;br /&gt;     cari := ada;&lt;br /&gt;  End;&lt;br /&gt;     &lt;br /&gt;Procedure TambahBlk; {Tambah Belakang sebenarnya hanya menggunakan prosedur Buat}&lt;br /&gt;  Begin&lt;br /&gt;     writeln;&lt;br /&gt;     write('Masukkan Data Yang Akan Ditambahkan Dibelakang Data    = '); readln(x);&lt;br /&gt;     Buat;&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Procedure AmbilDpn; {Prosedur mengambil depan untuk menjadi data "x"}&lt;br /&gt;Var bantu : antrian;{Akan tetapi, tidak dilakukan apapun terhadap data ini??}&lt;br /&gt;  Begin&lt;br /&gt;     writeln;&lt;br /&gt;     write('     Elemen Terdepan Data Adalah    = '); write(dpn^.isi);&lt;br /&gt;     write('Tekan ENTER utk Ambil Data Tersebut = '); readln;&lt;br /&gt;     baru := dpn;&lt;br /&gt;     If not(isEmpty) then&lt;br /&gt;        Begin&lt;br /&gt;           dpn   := dpn^.next;&lt;br /&gt;           baru  := nil;&lt;br /&gt;        End&lt;br /&gt;     Else write('antrian kosong');&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Procedure HapusDpn; {Prosedur untuk menhapus data terdepan}&lt;br /&gt;Var bantu : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     If not (isEmpty) then&lt;br /&gt;        Begin&lt;br /&gt;           dpn := dpn^.next;&lt;br /&gt;           If dpn=nil then blk := nil;&lt;br /&gt;        End&lt;br /&gt;     Else write('antrian kosong');&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Procedure HapusBlk; {Prosedur untuk menghapus data belakang}&lt;br /&gt;Var bantu, baru : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     bantu := dpn;&lt;br /&gt;     If not (isEmpty) then&lt;br /&gt;        Begin&lt;br /&gt;           While bantu^.next^.next &lt;&gt; nil do bantu  := bantu^.next;&lt;br /&gt;           new(baru);&lt;br /&gt;           baru        := bantu^.next;&lt;br /&gt;           bantu^.next := nil;&lt;br /&gt;           baru        := nil;&lt;br /&gt;        End&lt;br /&gt;     Else write('antrian kosong');&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Procedure HapusX; {Prosedur untuk menghapus data "X"}&lt;br /&gt;Var bantu, hapus : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     bantu := dpn;&lt;br /&gt;     new(hapus);&lt;br /&gt;     If cari(x)=true then&lt;br /&gt;        Begin&lt;br /&gt;           hapus       := bantu^.next;&lt;br /&gt;           bantu^.next := hapus^.next;&lt;br /&gt;           hapus       := nil;&lt;br /&gt;        End&lt;br /&gt;     Else bantu := bantu^.next;&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Procedure SisipDpn; {Prosedur untuk Sisip Depan, tetapi belum berhasil sampai saat ini}&lt;br /&gt;Var baru, bantu : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     bantu := dpn;&lt;br /&gt;     While bantu^.next &lt;&gt; nil do&lt;br /&gt;        Begin&lt;br /&gt;           If bantu^.next^.isi = x then&lt;br /&gt;              Begin&lt;br /&gt;                 new(baru);&lt;br /&gt;                 baru^.isi   := y;&lt;br /&gt;                 baru^.next  := bantu^.next;&lt;br /&gt;                 bantu^.next := baru;&lt;br /&gt;              End;&lt;br /&gt;           bantu := bantu^.next;&lt;br /&gt;        End;&lt;br /&gt;  End;&lt;br /&gt;      &lt;br /&gt;Procedure SisipBlk; {Prosedur untuk Sisip BElakang, tetapi belum berhasil sampai saat ini}&lt;br /&gt;Var bantu, baru : antrian;&lt;br /&gt;  Begin&lt;br /&gt;     bantu := dpn;&lt;br /&gt;        While bantu^.next &lt;&gt; nil do&lt;br /&gt;           Begin&lt;br /&gt;              If bantu^.isi=x then&lt;br /&gt;                 Begin&lt;br /&gt;                    new(baru);&lt;br /&gt;                    baru^.isi   := y;&lt;br /&gt;                    baru^.next  := bantu^.next;&lt;br /&gt;                    bantu^.next := baru;&lt;br /&gt;                 End;&lt;br /&gt;              bantu := bantu^.next;&lt;br /&gt;           End;&lt;br /&gt;  End;&lt;br /&gt;  &lt;br /&gt;Procedure Identitas; {Prosedur Identitas akan muncul pada program}&lt;br /&gt;  Begin&lt;br /&gt;     gotoXY(10, 1); write('Program "Q U E U E"');&lt;br /&gt;     gotoXY(10, 2); write('Muchamad Dachlan Zaim (M0507028)');&lt;br /&gt;     gotoXY(10, 3); write('Ilmu Komputer 2007');&lt;br /&gt;     gotoXY(10, 4); write('Tanggal 20 Mei 2008, 18.00 WIB');&lt;br /&gt;     gotoXY(6, 5); write('=====================================================================');&lt;br /&gt;  End;&lt;br /&gt;&lt;br /&gt;Procedure Menu; {Prosedur untuk menampilkan semuanya, termasuk menu utama juga !!!}&lt;br /&gt;Var pil,lagi : char;&lt;br /&gt;  Begin&lt;br /&gt;     clrscr;&lt;br /&gt;     Identitas;&lt;br /&gt;     Cetak;&lt;br /&gt;     gotoXY(30,10); write('"==== Modifikasi Data QUEUE ===="');&lt;br /&gt;     gotoXY(10,12); write('a. Input Awal');&lt;br /&gt;     gotoXY(10,13); write('b. Cari Data X');&lt;br /&gt;     gotoXY(10,14); write('c. Tambah Data di Belakang/ Enqueue');&lt;br /&gt;     gotoXY(10,15); write('d. Ambil Data Teratas dan Simpan di X');&lt;br /&gt;     gotoXY(10,16); write('e. Hapus Data Terdepan');&lt;br /&gt;     gotoXY(10,17); write('f. Hapus Data Belakang');&lt;br /&gt;     gotoXY(10,18); write('g. Hapus Data X');&lt;br /&gt;     gotoXY(10,19); write('h. Sisip Data di Depan');&lt;br /&gt;     gotoXY(10,20); write('i. Sisip Data di Belakang');&lt;br /&gt;     gotoXY(10,21); write('j. Keluar');&lt;br /&gt;&lt;br /&gt;     Repeat&lt;br /&gt;        gotoXY(40,23); Clreol; write('Pilihan anda (a-j)   = '); readln(pil);&lt;br /&gt;&lt;br /&gt;     CASE upcase(pil) OF&lt;br /&gt;        'A'  : Begin&lt;br /&gt;               lagi := 'Y';&lt;br /&gt;               clrscr;&lt;br /&gt;               gotoXY(10,5); write('=== Daftar Makanan "RestoRUN" ===');writeln;&lt;br /&gt;               While upcase(lagi)='Y' do&lt;br /&gt;                 Begin&lt;br /&gt;                   write('         Nama Makanan   = '); readln(x);writeln;&lt;br /&gt;                   buat;&lt;br /&gt;                   repeat&lt;br /&gt;                   write('         Ada lagi (Y/T) ? '); readln(lagi);writeln;&lt;br /&gt;                   until upcase(lagi) in['Y','T']&lt;br /&gt;                 End;&lt;br /&gt;               cetak; readln; menu;&lt;br /&gt;               End;&lt;br /&gt;        'B'  : Begin&lt;br /&gt;               clrscr;&lt;br /&gt;               gotoXY(25,6); write('Makanan Apa Yang anda Cari  =  '); readln(x);&lt;br /&gt;                   If not(isEmpty) then&lt;br /&gt;                   Begin&lt;br /&gt;                      cari(x);&lt;br /&gt;                      If (cari(x)=true) then&lt;br /&gt;                           Begin&lt;br /&gt;                            gotoXY(25,10); write('Makanan "',x,'" Tersedia Dalam Daftar Makanan   ');&lt;br /&gt;                           End&lt;br /&gt;                      Else Begin&lt;br /&gt;                            gotoXY(25,10); write('Makanan "',x,'" Tidak Tersedia Di Daftar Makanan');&lt;br /&gt;                           End;&lt;br /&gt;                   End&lt;br /&gt;                   Else write('antrian kosong');&lt;br /&gt;               cetak; readln; menu;&lt;br /&gt;               End;&lt;br /&gt;        'C'  : Begin tambahblk; cetak; readln; menu; end;&lt;br /&gt;        'D'  : Begin ambildpn;  cetak; readln; menu; end;&lt;br /&gt;        'E'  : Begin writeln; write('Tekan ENTER Untuk Hapus Depan...   '); readln; hapusdpn; cetak; readln; menu;End;&lt;br /&gt;        'F'  : Begin writeln; write('Tekan ENTER Untuk Hapus Belakang...'); readln; hapusblk; cetak; readln; menu;End;&lt;br /&gt;        'G'  : Begin&lt;br /&gt;                    write('     Data Yang Akan Dihapus = '); readln(x);&lt;br /&gt;                    hapusX; cetak; readln; menu;&lt;br /&gt;               End;&lt;br /&gt;        'H'  : Begin&lt;br /&gt;                    write('     Data Yang Akan Disisipkan    =   '); readln(y); writeln;&lt;br /&gt;                    write('     Disisip Didepan Data         =   '); readln(x);&lt;br /&gt;                    If cari(x)=true then sisipdpn;&lt;br /&gt;               cetak; readln; menu;&lt;br /&gt;               End;&lt;br /&gt;        'I'  : Begin&lt;br /&gt;                    write('     Data Yang Akan Disisipkan    =   '); readln(y); writeln;&lt;br /&gt;                    write('     Disisip Dibelakang Data      =   '); readln(x);&lt;br /&gt;                    If cari(x)=true then sisipblk;&lt;br /&gt;               cetak; readln; menu;&lt;br /&gt;               End;&lt;br /&gt;        'J'  : donewincrt;&lt;br /&gt;        End;&lt;br /&gt;        Until upcase(pil) in['A'..'J'];&lt;br /&gt;   End;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;{----MAIN PROGRAM----}&lt;br /&gt;Begin&lt;br /&gt;  screensize.x := 95;&lt;br /&gt;  screensize.y := 400;&lt;br /&gt;  menu;&lt;br /&gt;End.{AKHIR PROGRAM UTAMA}</description></item><item><title>Is it possible for a compiler to be ISO 7185 Pascal compliant and Borland Delphi compliant as well?</title><link>http://pascalprog.blogspot.com/2008/02/is-it-possible-for-compiler-to-be-iso.html</link><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:13:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-5717754433089382724</guid><description>&lt;p&gt;GNU GPC is such a compiler. It will take switches that configure it for  either ISO 7185 use or Borland use. Note that several of the differences between  the languages are compatible between the languages without the need for an  option. Here is a list of ISO 7185 to Delphi differences, and whether they  require a configuration option, and why. See the section "Differences between  the languages", for details on each difference.&lt;/p&gt; &lt;p&gt;1. Procedure and function parameters.&lt;/p&gt; &lt;p&gt;Requires a configuration option: No&lt;/p&gt; &lt;p&gt;Reason: In delphi mode, the keyword procedure or function in a procedure or  function header is an error. In ISO 7185 Pascal, it introduces a procedure or  function parameter. This makes it essentially an extension to Delphi.&lt;/p&gt; &lt;p&gt;2. Interprocedural gotos.&lt;/p&gt; &lt;p&gt;Requires a configuration option: No&lt;/p&gt; &lt;p&gt;Reason: Such gotos cause an error in Delphi, so it behaves as simple  extension.&lt;/p&gt; &lt;p&gt;3. File buffer access, "get" and "put" procedures.&lt;/p&gt; &lt;p&gt;Requires a configuration option: No&lt;/p&gt; &lt;p&gt;Reason: There are no get or put procedures in Delphi, and access to a file  variable is illegal, so both of these act as simple extensions.&lt;/p&gt; &lt;p&gt;4. Sized variant record allocation.&lt;/p&gt; &lt;p&gt;Requires a configuration option: No&lt;/p&gt; &lt;p&gt;Reason: Allocating a variant record with new with Delphi is illegal, so it  behaves as a simple extension.&lt;/p&gt; &lt;p&gt;5. "pack" and "unpack" functions.&lt;/p&gt; &lt;p&gt;Requires a configuration option: No&lt;/p&gt; &lt;p&gt;Reason: There are no pack or unpack procedures in Delphi, so it behaves as a  simple extension. Note that in most cases, pack and unpack don't need to  actually do anything, since arrays are allocated to the nearest byte on most  microprocessors.&lt;/p&gt; &lt;p&gt;6. { and (*, } and *) are not synonyms.&lt;/p&gt; &lt;p&gt;Requires a configuration option: Yes&lt;/p&gt; &lt;p&gt;Reason: There is no way to have a single behavior that covers both the ISO  7185 and Delphi definition of how comments work.&lt;/p&gt; &lt;p&gt;7. Requires compiler directives to make a standard program.&lt;/p&gt; &lt;p&gt;Requires a configuration option: No&lt;/p&gt; &lt;p&gt;Reason: The compiler can simply ignore this comment.&lt;/p&gt; &lt;p&gt;8. End of line returns ASCII codes.&lt;/p&gt; &lt;p&gt;Requires a configuration option: Yes (or a different runtime library)&lt;/p&gt; &lt;p&gt;Reason: There is no way to satisfy both program standards. An eoln is either  a space or the underlying ASCII characters.&lt;/p&gt; &lt;p&gt;9. Default field widths.&lt;/p&gt; &lt;p&gt;Requires a configuration option: Yes (or a different runtime library)&lt;/p&gt; &lt;p&gt;Reason: The basic behavior of the compiler must be changed.&lt;/p&gt; &lt;p&gt;So of the 9 basic differences between the standards, 3 of them are mutually  incompatible between the two languages, and require options to change the basic  workings of the compiler. The 6 remaining differences that are simply additions  to the Delphi language can also be thought of as "freebies" that can be added to  any Delphi compatible compiler in order to enable it to be closer to the ISO  7185 standard without compromising its Delphi processing in any way.&lt;/p&gt;</description></item><item><title>Is it possible to write in a Pascal subset that will be acceptable to both ISO 7185 Pascal and Delphi?</title><link>http://pascalprog.blogspot.com/2008/02/is-it-possible-to-write-in-pascal.html</link><category>Acceptable in Delphi</category><category>Delphi</category><category>Pascal</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:11:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-6401422855526867873</guid><description>&lt;p&gt;Sure. You can use the ISO 7185 "level 0" Pascal with the following  omissions:&lt;/p&gt; &lt;p&gt;1. Do not use procedure or function parameters. These have different syntax  in ISO 7185 and Delphi.&lt;/p&gt; &lt;p&gt;2. Do not use intraprocedural gotos (gotos that leave the current procedure  or function). If you need a deep nested bailout to a higher level procedure, try  setting an error variable and checking that after each procedure/function call  that might have an error, then skipping either out of the routine, or to the  goto point.&lt;/p&gt; &lt;p&gt;3. Do not use file buffer handling (such as f^ accesses, where f is a file),  nor the built in routines "get" and "put". Basically, this just means you cannot  use the lookahead buffering that ISO 7185 Pascal provides.&lt;/p&gt; &lt;p&gt;4. Do not size your variant records with "new". Delphi knows about variant  records, but not how to size them (at least not the standard way). This will  have no functional effect on your program, it will just take more runtime  space.&lt;/p&gt; &lt;p&gt;5. Always use the keyword "packed" on a string that is intended to be printed  with "writeln". Delphi does not require this, but ISO 7185 does.&lt;/p&gt; &lt;p&gt;6. Always include the files "input" and/or "output" in the program header if  they are used in the program (and remember that write/read with no file  parameter is a defacto reference). Delphi simply ignores these header  parameters, so they don't hurt.&lt;/p&gt; &lt;p&gt;7. Always use format specifications to set the width that will be output for  integers. This will remove differences from varying default fields.&lt;/p&gt; &lt;p&gt;8. Don't use external files other than input and output, since most Delphi  does nothing with header files).&lt;/p&gt; &lt;p&gt;9. Borland Delphi has the requirement that an&lt;/p&gt; &lt;p&gt;{$APPTYPE CONSOLE}&lt;/p&gt; &lt;p&gt;must exist at the top after the program header. If your non-Delphi compiler  ignores this as a comment, then you can add it to also be compatible with  Delphi. If your ISO 7185 compiler also treats "$" in a comment as an option, you  are going to have to be prepared to remove it as need be.&lt;/p&gt; &lt;p&gt;Finally, note that you MUST also comply with the ISO 7185 standard  requirements for this to work. For example, ISO 7185 forbids gotos into program  structures like "for" loops, etc, whereas delphi does not. There are many other  such restrictions of ISO 7185 that are relaxed in Delphi, not to mention the  many Delphi extensions that you need to refrain from using (of course, all  Pascal compilers have extensions, so that would apply to them as well). Also  remember: Pascal originally had no "string" type. This might seem strange, but C  (for example) does not have one either. Instead, you use an array of characters  (which is not the same thing!). See other sections of this FAQ.&lt;/p&gt; &lt;p&gt;The old bit of cross compiler checking that applies here is to run a check  compile on all of the different compilers you plan to be compatible with  frequently. This will tell you about problems with different compilers before  they get out of hand.&lt;/p&gt; &lt;p&gt;For this author's point of view, I lived with mutiple Pascal compilers for  years, and made it work by isolating system specific code to modules that  implemented that on a particular platform. For example, I had a set of routines  in a module I called "basicio.pas" that contained things like opentext(f,  filename), closetext(f) and similar functions. Then, this module is simply  recoded or swapped out to move to a different compiler.&lt;/p&gt;</description></item><item><title>Antrian Melingkar</title><link>http://pascalprog.blogspot.com/2008/02/antrian-melingkar.html</link><category>Antrian</category><category>program</category><category>Scripts</category><category>Source Code</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:11:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-8877612574270580299</guid><description>Antrian Melingkar&lt;br /&gt;uses wincrt;&lt;br /&gt;type lingkar=array[1..10] of char;&lt;br /&gt;type ling=record&lt;br /&gt;nilai:lingkar;&lt;br /&gt;dep:integer;&lt;br /&gt;bel:integer;&lt;br /&gt;isi:integer;&lt;br /&gt;end;&lt;br /&gt;var n:integer;&lt;br /&gt;antrian:ling;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;procedure push(var antrian:ling;x:char);&lt;br /&gt;7&lt;br /&gt;begin&lt;br /&gt;if antrian.isi=n then write('antrian penuh')&lt;br /&gt;else&lt;br /&gt;begin&lt;br /&gt;if antrian.bel=n then antrian.bel:=1&lt;br /&gt;else antrian.bel:=antrian.bel+1;&lt;br /&gt;antrian.nilai[antrian.bel]:=x;&lt;br /&gt;antrian.isi:=antrian.isi+1;&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;procedure pop(var antrian:ling;var x:char);&lt;br /&gt;begin&lt;br /&gt;if antrian.isi=0 then write('antrian kosong')&lt;br /&gt;else&lt;br /&gt;begin&lt;br /&gt;antrian.dep:=antrian.dep+1;&lt;br /&gt;if antrian.dep=n+1 then antrian.dep:=1;&lt;br /&gt;x:=antrian.nilai[antrian.dep];&lt;br /&gt;antrian.nilai[antrian.dep]:=' ';&lt;br /&gt;antrian.isi:=antrian.isi-1;&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;var i,ingin:integer;&lt;br /&gt;x:char;&lt;br /&gt;begin&lt;br /&gt;n:=5;&lt;br /&gt;i:=0;&lt;br /&gt;repeat&lt;br /&gt;i:=i+1;&lt;br /&gt;write('antrian ke - ',i,' = ');readln(x);&lt;br /&gt;push(antrian,x);&lt;br /&gt;until i=n;&lt;br /&gt;for i:=1 to antrian.bel do write(antrian.nilai[i],' ');&lt;br /&gt;readln;&lt;br /&gt;repeat&lt;br /&gt;write('Anda ingin 0. Udah, 1. Push, 2. pop');readln(ingin);&lt;br /&gt;if ingin&lt;&gt;0 then&lt;br /&gt;case ingin of&lt;br /&gt;1: begin&lt;br /&gt;write('nilai yang akan masuk : ');readln(x);&lt;br /&gt;push(antrian,x);&lt;br /&gt;for i:=1 to n do&lt;br /&gt;write(antrian.nilai[i],' ');&lt;br /&gt;writeln;&lt;br /&gt;end;&lt;br /&gt;2: begin&lt;br /&gt;x:=' ';&lt;br /&gt;pop(antrian,x);&lt;br /&gt;writeln('Data keluar = ',x);&lt;br /&gt;for i:=1 to n do&lt;br /&gt;write(antrian.nilai[i],' ');&lt;br /&gt;writeln;&lt;br /&gt;end;&lt;br /&gt;end&lt;br /&gt;until ingin=0;&lt;br /&gt;end.</description></item><item><title>Program Tumpukan</title><link>http://pascalprog.blogspot.com/2008/02/program-tumpukan.html</link><category>program</category><category>Scripts</category><category>Source Code</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:09:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-2461637187617953135</guid><description>Program Tumpukan;&lt;br /&gt;uses wincrt;&lt;br /&gt;const MaxElemen=5;&lt;br /&gt;type Tumpukan =record&lt;br /&gt;isi:array[1..MaxElemen] of integer;&lt;br /&gt;atas: 0..MaxElemen&lt;br /&gt;end;&lt;br /&gt;type isi=array[0..maxelemen] of integer;&lt;br /&gt;const isilama1:isi=(3,7,2,6,4,8);&lt;br /&gt;isibaru1:isi=(4,8,3,6,5,1);&lt;br /&gt;var&lt;br /&gt;Nilailama,Nilaibaru:isi;&lt;br /&gt;T:tumpukan;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;Procedure Ganti_NilaiStack(T:tumpukan;Nilailama,Nilaibaru:isi);&lt;br /&gt;var&lt;br /&gt;penuh,habis: boolean;&lt;br /&gt;x,i:integer;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;procedure push( var T:tumpukan; var penuh:boolean;x:integer);&lt;br /&gt;begin&lt;br /&gt;if T.atas = maxElemen then penuh:=true&lt;br /&gt;else&lt;br /&gt;begin&lt;br /&gt;penuh :=false;&lt;br /&gt;T.isi[T.atas]:=x;&lt;br /&gt;T.atas:=T.atas+1;&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;procedure pop(var T:tumpukan;var habis:boolean; var x:integer);&lt;br /&gt;begin&lt;br /&gt;if T.atas =0 then habis:=true&lt;br /&gt;else&lt;br /&gt;begin&lt;br /&gt;habis:=false;&lt;br /&gt;T.atas:=T.atas-1;&lt;br /&gt;x:=T.isi[T.atas];&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;begin&lt;br /&gt;clrscr;&lt;br /&gt;write('Nilai Lama Sebelum Masuk Tumpukan : ');&lt;br /&gt;for i:=0 to maxelemen do&lt;br /&gt;write(isilama1[i]);&lt;br /&gt;writeln;&lt;br /&gt;write('Nilai Baru Sebelum Masuk Tumpukan : ');&lt;br /&gt;for i:=0 to maxelemen do&lt;br /&gt;write(isibaru1[i]);&lt;br /&gt;writeln;&lt;br /&gt;penuh:=false;&lt;br /&gt;while penuh=false do&lt;br /&gt;begin&lt;br /&gt;push(T,penuh,Nilailama[T.atas]);&lt;br /&gt;end;&lt;br /&gt;write('Isi Tumpukan Lama : ');&lt;br /&gt;while T.atas&lt;&gt;0 do&lt;br /&gt;begin&lt;br /&gt;pop(T,habis,x);&lt;br /&gt;write(x);&lt;br /&gt;end;&lt;br /&gt;writeln;penuh:=false;&lt;br /&gt;while penuh=false do&lt;br /&gt;begin&lt;br /&gt;push(T,penuh,Nilaibaru[T.atas]);&lt;br /&gt;end;&lt;br /&gt;write('Isi Tumpukan Baru : ');&lt;br /&gt;while T.atas&lt;&gt;0 do&lt;br /&gt;begin&lt;br /&gt;pop(T,habis,x);&lt;br /&gt;write(x);&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;{---------------------------------------------------------------------}&lt;br /&gt;begin&lt;br /&gt;Nilailama:=isilama1;Nilaibaru:=isibaru1;&lt;br /&gt;Ganti_NilaiStack(T,Nilailama,Nilaibaru);&lt;br /&gt;readkey;&lt;br /&gt;end.</description></item><item><title>Is it possible to have a module (unit) under Delphi that converts it to ISO 7185 use?</title><link>http://pascalprog.blogspot.com/2008/02/is-it-possible-to-have-module-unit.html</link><category>ISO 7185</category><category>ISO Pascal</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:09:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-3270317729354249678</guid><description>&lt;p&gt;It is not possible for several reasons. First, there are several differences  between the languages that are purely syntactic in nature, such as the way  comments work. Second, there is no way to write, for example, file handling  functions that accept all types of files. Third, there are features such as  interprocedure gotos that only the compiler can implement.&lt;/p&gt; &lt;p&gt;I have seen many claims in the past that it is "easy to bridge the  differences between ISO Pascal and the Delphi language", but it is usually  apparent that those making the claim haven't read the ISO 7185 standard in any  detail. It simply isn't that easy.&lt;/p&gt;</description></item><item><title>Program Ganjil Genap</title><link>http://pascalprog.blogspot.com/2008/02/program-ganjil-genap.html</link><category>Even</category><category>Ganjil Genap</category><category>Odd</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:06:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-1124466572643449619</guid><description>Program ganjil_genap;&lt;br /&gt;uses wincrt;&lt;br /&gt;var&lt;br /&gt;bil, i,g1,g2,j1,j2,n: integer;&lt;br /&gt;rt1,rt2:real;&lt;br /&gt;begin&lt;br /&gt;write('Masukkan Banyaknya Data ' );readln(n);&lt;br /&gt;for i := 1 to n do&lt;br /&gt;begin&lt;br /&gt;write('Bilangan ke:',i ,' ');readln(bil);&lt;br /&gt;if bil mod 2 = 0 then&lt;br /&gt;j1:=j1 +1;&lt;br /&gt;g1:=g1+bil;&lt;br /&gt;if bil mod 2 =1 then&lt;br /&gt;j2:=j2+1;&lt;br /&gt;g2:=g2+bil;&lt;br /&gt;end;&lt;br /&gt;rt1:=g1/j1;&lt;br /&gt;rt2:=g2/j2;&lt;br /&gt;writeln('Jumlah bil. Ganjil=' ,j2);&lt;br /&gt;writeln('Jumlah bil. Genap=' ,j1);&lt;br /&gt;writeln('Rerata Ganjil=' ,rt2:4:2);&lt;br /&gt;writeln('Rerata Genap=' ,rt1:4:2);&lt;br /&gt;end.</description></item><item><title>Program Baca berpasangan</title><link>http://pascalprog.blogspot.com/2008/02/program-baca-berpasangan.html</link><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:04:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-5318654904968603201</guid><description>Program Baca_berpasangan;&lt;br /&gt;Uses WinCrt;&lt;br /&gt;Var&lt;br /&gt;X,Y,Rx,Ry,Jx,Jy : real;&lt;br /&gt;Nx,Ny,i : integer;&lt;br /&gt;Begin&lt;br /&gt;ClrScr;&lt;br /&gt;Write('Masukkan Banyaknya X :');Readln(Nx);&lt;br /&gt;Write('Masukkan Banyaknya Y :');Readln(Ny);&lt;br /&gt;If Nx = Ny then&lt;br /&gt;For i:=1 to Nx Do&lt;br /&gt;begin&lt;br /&gt;Write('Data X ke-',i,' = ');Readln(X);&lt;br /&gt;Write('Data Y ke-',i,' = ');Readln(Y);&lt;br /&gt;Jx:=Jx+X;&lt;br /&gt;Jy:=Jy+Y;&lt;br /&gt;end&lt;br /&gt;else if Nx &gt; Ny then&lt;br /&gt;begin&lt;br /&gt;For i:=1 to Ny Do&lt;br /&gt;begin&lt;br /&gt;Write('Data X ke-',i,' = ');Readln(X);&lt;br /&gt;Write('Data Y ke-',i,' = ');Readln(Y);&lt;br /&gt;Jx:=Jx+X;&lt;br /&gt;Jy:=Jy+Y;&lt;br /&gt;end;&lt;br /&gt;i:=Ny+1;&lt;br /&gt;Repeat&lt;br /&gt;Write('Data X ke-',i,' = ');Readln(X);&lt;br /&gt;Jx:=Jx+X;&lt;br /&gt;i:=i+1;&lt;br /&gt;until i&gt;Nx;&lt;br /&gt;end&lt;br /&gt;else if Nx &lt; Ny then&lt;br /&gt;begin&lt;br /&gt;For i:=1 to Nx Do&lt;br /&gt;begin&lt;br /&gt;Write('Data X ke-',i,' = ');Readln(X);&lt;br /&gt;Write('Data Y ke-',i,' = ');Readln(Y);&lt;br /&gt;Jx:=Jx+X;&lt;br /&gt;Jy:=Jy+Y;&lt;br /&gt;end;&lt;br /&gt;i:=Nx+1;&lt;br /&gt;Repeat&lt;br /&gt;Write('Data Y ke-',i,' = ');Readln(Y);&lt;br /&gt;Jy:=Jy+Y;&lt;br /&gt;i:=i+1;&lt;br /&gt;until i&gt;Ny;&lt;br /&gt;end;&lt;br /&gt;Rx:=Jx/Nx;&lt;br /&gt;Ry:=Jy/Ny;&lt;br /&gt;writeln('Rata-rata dari data X = ',Rx:6:2);&lt;br /&gt;writeln('Rata-rata dari data Y = ',Ry:6:2);&lt;br /&gt;end.</description></item><item><title>Differences between the languages Borland Delphi</title><link>http://pascalprog.blogspot.com/2008/02/differences-between-languages-borland.html</link><category>Blaise Pascal</category><category>Boolean</category><category>Borland Delphi</category><category>Comments</category><category>Differences</category><category>functions</category><category>No Buffer</category><category>No Sized</category><category>Numbers</category><category>procedure</category><category>Statements</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 22:01:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-2202775654024891772</guid><description>&lt;p&gt;Because Borland Delphi is a widely used version of Pascal, it is useful to  compare the two languages. Note that here are presented only the differences  between Borland Delphi and the basic ISO 7185 standard. Undiscussed are any  extensions provided by Borland Delphi. In other words, this section answers the  question "why doesn't my standard Pascal program run under Borland Delphi?", and  perhaps "what can I write in Borland Delphi that will also be compatible with  the ISO 7185 standard?".&lt;/p&gt; &lt;p&gt;1. Procedures and functions may not appear as parameters (it is true that it  can be done, but a non-standard syntax must be used).&lt;/p&gt; &lt;p&gt;2. Goto statements cannot reference targets outside procedure/function bodies  (so called "intraprocedural gotos").&lt;/p&gt; &lt;p&gt;3. No file buffer variable handling. Standard Pascal has file "buffer  variables", and "get" and "put" procedures to operate on them. This  functionality is not present in Borland Delphi.&lt;/p&gt; &lt;p&gt;4. No "sized" dynamic variable allocation. Given a variant record, the size  of a particular variant cannot be specified as per the standard. I.e., the  following statement is invalid:&lt;/p&gt; &lt;p&gt;new(p, t)&lt;/p&gt; &lt;p&gt;Where t is a variant record tag type.&lt;/p&gt; &lt;p&gt;5. The functions "pack" and "unpack" are not implemented.&lt;/p&gt; &lt;p&gt;6. { and (*, } and *) are not synonyms of each other as required by the  standard. Ie.:&lt;/p&gt; &lt;p&gt;{ comment *)&lt;/p&gt; &lt;p&gt;is not valid in Borland Delphi (Delphi uses the scheme of allowing the  different comment types to indicate nested comments).&lt;/p&gt; &lt;p&gt;7. It is not possible to construct a standard program without compiler  directives. At minimum:&lt;/p&gt; &lt;p&gt;{$APPTYPE CONSOLE}&lt;/p&gt; &lt;p&gt;is required.&lt;/p&gt; &lt;p&gt;8. Does not replace eoln with space as the standard requires. When reading  through the end of a line, the eoln character is supposed to be replaced with a  space in ISO 7185. Instead, reading through eoln in Borland Delphi gives the  character code for carriage return (13), followed by line feed (10).&lt;/p&gt; &lt;p&gt;9. Numbers and booleans are not printed out in their "default" field widths,  but are printed in the minimum amount of space. For example:&lt;/p&gt; &lt;p&gt;write('&gt;', 5, '&lt;');&lt;/p&gt; &lt;p&gt;Outputs:&lt;/p&gt; &lt;p&gt;&gt;5&lt;&lt;/p&gt; &lt;p&gt;in Delphi, but:&lt;/p&gt; &lt;p&gt;&gt; 5&lt;&lt;/p&gt; &lt;p&gt;(spaces depend on compiler integer width) in ISO 7185.&lt;/p&gt; &lt;p&gt;For booleans:&lt;/p&gt; &lt;p&gt;write('&gt;', true, '&lt;');&lt;/p&gt; &lt;p&gt;outputs:&lt;/p&gt; &lt;p&gt;&gt;true&lt;&lt;/p&gt; &lt;p&gt;in Delphi, but:&lt;/p&gt; &lt;p&gt;&gt; true&lt;&lt;/p&gt; &lt;p&gt;In ISO 7185.&lt;/p&gt;</description></item><item><title>Comparision of Pascal and Borland Delphi</title><link>http://pascalprog.blogspot.com/2008/02/comparision-of-pascal-and-borland.html</link><category>Blaise Pascal</category><category>Borland Delphi</category><category>Niklaus Wirth</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 2 Feb 2008 21:58:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-7168848589565362487</guid><description>Pascal is a programming language, developed in 1970 by Niklaus Wirth.&lt;br /&gt;&lt;br /&gt;An alternative dialect was created by Borland Corporation. Their language went through several versions and names, such as Turbo Pascal, Borland Pascal, and finally Delphi Pascal.&lt;br /&gt;&lt;br /&gt;This page briefly goes over the differences between those dialects of the language.&lt;br /&gt;&lt;br /&gt;The title of this page "Comparison between Pascal and Delphi" was chosen because Borland uses the name "Delphi" exclusively for their version of the language. It is correct to refer to "Pascal" in general as Niklaus Wirth's original language (and derivatives) and Borland's dialect as "Delphi". When referring to Borland's previous dialects, the terms "Turbo Pascal", and "Borland Pascal" apply.&lt;br /&gt;&lt;br /&gt;The Term ISO 7185 or ISO 7185 Pascal is used here as synonymous with Niklaus Wirth's programming language Pascal. The ISO 7185 standard is the standardized version of Niklaus Wirth's language, as he has stated several times.</description></item><item><title/><link>http://pascalprog.blogspot.com/2007/11/edit-pointers-pascal-supports-use-of.html</link><category>control structures</category><category>Data structures</category><category>enumerations</category><category>files</category><category>full stop</category><category>functions</category><category>inked lists</category><category>keyword</category><category>pointers</category><category>pointersl</category><category>procedures</category><category>semicolons</category><category>sets</category><category>statement block</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 24 Nov 2007 01:46:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-5561808066149854927</guid><description>&lt;p&gt;&lt;a name="Pointers" id="Pointers"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Pascal_%28programming_language%29&amp;amp;action=edit&amp;amp;section=8" title="Edit section: Pointers"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Pointers&lt;/span&gt;&lt;/h4&gt; &lt;p&gt;Pascal supports the use of &lt;a href="http://en.wikipedia.org/wiki/Pointer" title="Pointer"&gt;pointers&lt;/a&gt;:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw4"&gt;type&lt;/span&gt;&lt;br /&gt; a = ^b;&lt;br /&gt; b = &lt;span class="kw4"&gt;record&lt;/span&gt;&lt;br /&gt;       x: &lt;span class="kw4"&gt;Integer&lt;/span&gt;;&lt;br /&gt;       y: &lt;span class="kw4"&gt;Char&lt;/span&gt;;&lt;br /&gt;       z: a&lt;br /&gt;     &lt;span class="kw1"&gt;end&lt;/span&gt;;&lt;br /&gt;&lt;span class="kw1"&gt;var&lt;/span&gt;&lt;br /&gt; pointer_to_b: a;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;Here the variable &lt;i&gt;pointer_to_b&lt;/i&gt; is a pointer to the data type &lt;i&gt;b&lt;/i&gt;, a record. Pointers can be used before they are declared. This is an exception to the rule that things must be declared before they are used. To create a new record and assign the values &lt;i&gt;10&lt;/i&gt; and &lt;i&gt;A&lt;/i&gt; to the fields &lt;i&gt;a&lt;/i&gt; and &lt;i&gt;b&lt;/i&gt; in the record, the commands would be;&lt;/p&gt; &lt;pre&gt;  &lt;b&gt;new&lt;/b&gt;(pointer_to_b);&lt;br /&gt;&lt;/pre&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;pointer_to_b^.&lt;span class="me1"&gt;x&lt;/span&gt; := &lt;span class="nu0"&gt;10&lt;/span&gt;;&lt;br /&gt; pointer_to_b^.&lt;span class="me1"&gt;y&lt;/span&gt; := &lt;span class="st0"&gt;'A'&lt;/span&gt;;&lt;br /&gt; pointer_to_b^.&lt;span class="me1"&gt;z&lt;/span&gt; := &lt;span class="kw2"&gt;nil&lt;/span&gt;;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;This could also be done using the &lt;b&gt;with&lt;/b&gt; statement, as follows&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw3"&gt;new&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;pointer_to_b&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt; with pointer_to_b^ &lt;span class="kw1"&gt;do&lt;/span&gt;&lt;br /&gt;   &lt;span class="kw1"&gt;begin&lt;/span&gt;&lt;br /&gt;       x := &lt;span class="nu0"&gt;10&lt;/span&gt;;&lt;br /&gt;       y := &lt;span class="st0"&gt;'A'&lt;/span&gt;;&lt;br /&gt;       z := &lt;span class="kw2"&gt;nil&lt;/span&gt;&lt;br /&gt;   &lt;span class="kw1"&gt;end&lt;/span&gt;;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;Note that inside of the scope of the &lt;b&gt;with&lt;/b&gt; statement, the compiler knows that a and b refer to the subfields of the record pointer &lt;b&gt;pointer_to_b&lt;/b&gt; and not to the record b or the pointer type a.&lt;/p&gt; &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Linked_list" title="Linked list"&gt;Linked lists&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Stack_%28data_structure%29" title="Stack (data structure)"&gt;stacks&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Queue_%28data_structure%29" title="Queue (data structure)"&gt;queues&lt;/a&gt; can be created by including a pointer type field (c) in the record (see also &lt;a href="http://en.wikipedia.org/wiki/Nil" title="Nil"&gt;nil&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Null_%28computer%29" title="Null (computer)"&gt;null (computer)&lt;/a&gt;).&lt;/p&gt; &lt;p&gt;&lt;a name="Control_structures" id="Control_structures"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Pascal_%28programming_language%29&amp;amp;action=edit&amp;amp;section=9" title="Edit section: Control structures"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Control structures&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;Pascal is a &lt;a href="http://en.wikipedia.org/wiki/Structured_programming" title="Structured programming"&gt;structured programming&lt;/a&gt; language, meaning that the flow of control is structured into standard statements, ideally without '&lt;a href="http://en.wikipedia.org/wiki/Goto_%28command%29" title="Goto (command)"&gt;go to&lt;/a&gt;' commands.&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw1"&gt;while&lt;/span&gt; a &lt;&gt; b &lt;span class="kw1"&gt;do&lt;/span&gt; &lt;span class="kw3"&gt;writeln&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'Waiting'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;if&lt;/span&gt; a &gt; b &lt;span class="kw1"&gt;then&lt;/span&gt;&lt;br /&gt; &lt;span class="kw3"&gt;writeln&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'Condition met'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;else&lt;/span&gt;&lt;br /&gt; &lt;span class="kw3"&gt;writeln&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'Condition false'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;for&lt;/span&gt; i := &lt;span class="nu0"&gt;1&lt;/span&gt; &lt;span class="kw1"&gt;to&lt;/span&gt; &lt;span class="nu0"&gt;10&lt;/span&gt; &lt;span class="kw1"&gt;do&lt;/span&gt; &lt;span class="kw3"&gt;writeln&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'Iteration: '&lt;/span&gt;, i:&lt;span class="nu0"&gt;1&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;repeat&lt;/span&gt; a := a + &lt;span class="nu0"&gt;1&lt;/span&gt; &lt;span class="kw1"&gt;until&lt;/span&gt; a = &lt;span class="nu0"&gt;10&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;&lt;a name="Procedures_and_functions" id="Procedures_and_functions"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Pascal_%28programming_language%29&amp;amp;action=edit&amp;amp;section=10" title="Edit section: Procedures and functions"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Procedures and functions&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;Pascal structures programs into procedures and functions.&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw2"&gt;program&lt;/span&gt; mine&lt;span class="br0"&gt;(&lt;/span&gt;output&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span class="kw1"&gt;var&lt;/span&gt; i : &lt;span class="kw4"&gt;integer&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt; &lt;span class="kw2"&gt;procedure&lt;/span&gt; print&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw1"&gt;var&lt;/span&gt; j: &lt;span class="kw4"&gt;integer&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;   &lt;span class="kw2"&gt;function&lt;/span&gt; next&lt;span class="br0"&gt;(&lt;/span&gt;k: &lt;span class="kw4"&gt;integer&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;: &lt;span class="kw4"&gt;integer&lt;/span&gt;;&lt;br /&gt;   &lt;span class="kw1"&gt;begin&lt;/span&gt;&lt;br /&gt;     next := k + &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;br /&gt;   &lt;span class="kw1"&gt;end&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt; &lt;span class="kw1"&gt;begin&lt;/span&gt;&lt;br /&gt;   &lt;span class="kw3"&gt;writeln&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'The total is: '&lt;/span&gt;, j&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;   j := next&lt;span class="br0"&gt;(&lt;/span&gt;j&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span class="kw1"&gt;end&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;begin&lt;/span&gt;&lt;br /&gt; i := &lt;span class="nu0"&gt;1&lt;/span&gt;;&lt;br /&gt; &lt;span class="kw1"&gt;while&lt;/span&gt; i &lt;= &lt;span class="nu0"&gt;10&lt;/span&gt; &lt;span class="kw1"&gt;do&lt;/span&gt; print&lt;span class="br0"&gt;(&lt;/span&gt;i&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;end&lt;/span&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;Procedures and functions can nest to any depth, and the 'program' construct is the logical outermost block.&lt;/p&gt; &lt;p&gt;Each procedure or function can have its own declarations of goto labels, constants, types, variables, and other procedures and functions, which must all be in that order. This ordering requirement was originally intended to allow efficient single-pass compilation. However, in some dialects the strict ordering requirement of declaration sections is not required.&lt;/p&gt;</description></item><item><title>Language constructs 1</title><link>http://pascalprog.blogspot.com/2007/11/language-constructs-1.html</link><category>procedureal language</category><category>records</category><category>type definitions</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 24 Nov 2007 01:43:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-4119215938407666913</guid><description>&lt;p&gt;Pascal, in its original form, is a purely &lt;a href="http://en.wikipedia.org/wiki/Procedural_language" title="Procedural language"&gt;procedural language&lt;/a&gt; and includes the traditional array of Algol-like control structures with reserved words such as &lt;b&gt;if&lt;/b&gt;, &lt;b&gt;then&lt;/b&gt;, &lt;b&gt;else&lt;/b&gt;, &lt;b&gt;while&lt;/b&gt;, &lt;b&gt;for&lt;/b&gt;, and so on. However, pascal also has many data structuring facilities and other abstractions which were not included in the original &lt;a href="http://en.wikipedia.org/wiki/Algol60" title="Algol60"&gt;Algol60&lt;/a&gt;, like &lt;a href="http://en.wikipedia.org/wiki/Type_system" title="Type system"&gt;type definitions&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Record_%28computer_science%29" title="Record (computer science)"&gt;records&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Pointer" title="Pointer"&gt;pointers&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Enumerated_type" title="Enumerated type"&gt;enumerations&lt;/a&gt;, and &lt;a href="http://en.wikipedia.org/wiki/Set" title="Set"&gt;sets&lt;/a&gt;. Such constructs were in part inherited or inspired from &lt;a href="http://en.wikipedia.org/wiki/Simula67" title="Simula67"&gt;Simula67&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Algol68" title="Algol68"&gt;Algol68&lt;/a&gt;, and &lt;a href="http://en.wikipedia.org/wiki/Niklaus_Wirth" title="Niklaus Wirth"&gt;Niklaus Wirth&lt;/a&gt;'s own &lt;a href="http://en.wikipedia.org/wiki/AlgolW" title="AlgolW"&gt;AlgolW&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name="Hello_world" id="Hello_world"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Pascal_%28programming_language%29&amp;amp;action=edit&amp;amp;section=6" title="Edit section: Hello world"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Hello world&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;Pascal programs start with the &lt;b&gt;program&lt;/b&gt; &lt;a href="http://en.wikipedia.org/wiki/Keyword_%28computer_programming%29" title="Keyword (computer programming)"&gt;keyword&lt;/a&gt; with a list of external file descriptors as parameters; then follows the main &lt;a href="http://en.wikipedia.org/wiki/Statement_block" title="Statement block"&gt;statement block&lt;/a&gt; encapsulated by the &lt;b&gt;begin&lt;/b&gt; and &lt;b&gt;end&lt;/b&gt; keywords. &lt;a href="http://en.wikipedia.org/wiki/Semicolon" title="Semicolon"&gt;Semicolons&lt;/a&gt; separate statements, and the &lt;a href="http://en.wikipedia.org/wiki/Full_stop" title="Full stop"&gt;full stop&lt;/a&gt; ends the whole program (or &lt;i&gt;unit&lt;/i&gt;). &lt;a href="http://en.wikipedia.org/wiki/Letter_case" title="Letter case"&gt;Letter case&lt;/a&gt; is ignored in Pascal source. Some compilers, Turbo Pascal among them, have made the &lt;b&gt;program&lt;/b&gt; keyword optional.&lt;/p&gt; &lt;p&gt;Here is an example of the source code in use for a very simple program:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw2"&gt;program&lt;/span&gt; HelloWorld&lt;span class="br0"&gt;(&lt;/span&gt;output&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span class="kw1"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;span class="kw3"&gt;writeln&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'Hello, World!'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;end&lt;/span&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;&lt;a name="Data_structures" id="Data_structures"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Pascal_%28programming_language%29&amp;amp;action=edit&amp;amp;section=7" title="Edit section: Data structures"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Data structures&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;Pascal's &lt;i&gt;simple&lt;/i&gt; (atomic) types are &lt;a href="http://en.wikipedia.org/wiki/Floating_point" title="Floating point"&gt;real&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Integer_%28computer_science%29" title="Integer (computer science)"&gt;integer&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Character_%28computing%29" title="Character (computing)"&gt;character&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Boolean_type" title="Boolean type"&gt;boolean&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Enumerated_type" title="Enumerated type"&gt;enumerations&lt;/a&gt;, a new type constructor introduced with Pascal:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw1"&gt;var&lt;/span&gt;&lt;br /&gt;r: &lt;span class="kw4"&gt;Real&lt;/span&gt;;&lt;br /&gt;i: &lt;span class="kw4"&gt;Integer&lt;/span&gt;;&lt;br /&gt;c: &lt;span class="kw4"&gt;Char&lt;/span&gt;;&lt;br /&gt;b: &lt;span class="kw4"&gt;Boolean&lt;/span&gt;;&lt;br /&gt;e: &lt;span class="br0"&gt;(&lt;/span&gt;apple, pear, banana, orange, lemon&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;Subranges of any ordinal type (any simple type except real) can be made:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw1"&gt;var&lt;/span&gt;&lt;br /&gt;x: &lt;span class="nu0"&gt;1&lt;/span&gt;..&lt;span class="nu0"&gt;10&lt;/span&gt;;&lt;br /&gt;y: &lt;span class="st0"&gt;'a'&lt;/span&gt;..&lt;span class="st0"&gt;'z'&lt;/span&gt;;&lt;br /&gt;z: pear..&lt;span class="me1"&gt;orange&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;In contrast with other programming languages Pascal supports set type:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw1"&gt;var&lt;/span&gt;&lt;br /&gt;set1: &lt;span class="kw4"&gt;set&lt;/span&gt; &lt;span class="kw1"&gt;of&lt;/span&gt; &lt;span class="nu0"&gt;1&lt;/span&gt;..&lt;span class="nu0"&gt;10&lt;/span&gt;;&lt;br /&gt;set2: &lt;span class="kw4"&gt;set&lt;/span&gt; &lt;span class="kw1"&gt;of&lt;/span&gt; &lt;span class="st0"&gt;'a'&lt;/span&gt;..&lt;span class="st0"&gt;'z'&lt;/span&gt;;&lt;br /&gt;set3: &lt;span class="kw4"&gt;set&lt;/span&gt; &lt;span class="kw1"&gt;of&lt;/span&gt; pear..&lt;span class="me1"&gt;orange&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;A set is fundamental concept for modern mathematics, and many algorithms are defined with sets usage. So, an implementation of such algorithm is very suitable for Pascal. Also, set's operations may be realized faster. For example, for many Pascal compilers:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw1"&gt;if&lt;/span&gt; i &lt;span class="kw1"&gt;in&lt;/span&gt; &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;5&lt;/span&gt;..&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt; &lt;span class="kw1"&gt;then&lt;/span&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;is faster, than&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw1"&gt;if&lt;/span&gt; &lt;span class="br0"&gt;(&lt;/span&gt;i&gt;&lt;span class="nu0"&gt;4&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &lt;span class="kw3"&gt;and&lt;/span&gt; &lt;span class="br0"&gt;(&lt;/span&gt;i&lt;&lt;span class="nu0"&gt;11&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &lt;span class="kw1"&gt;then&lt;/span&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;Types can be defined from other types using type declarations:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw4"&gt;type&lt;/span&gt;&lt;br /&gt;x = &lt;span class="kw4"&gt;Integer&lt;/span&gt;;&lt;br /&gt;y = x;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;Further, complex types can be constructed from simple types:&lt;/p&gt; &lt;div dir="ltr"&gt; &lt;pre class="source-pascal"&gt;&lt;span class="kw4"&gt;type&lt;/span&gt;&lt;br /&gt;a = &lt;span class="kw4"&gt;Array&lt;/span&gt; &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;..&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt; &lt;span class="kw1"&gt;of&lt;/span&gt; &lt;span class="kw4"&gt;Integer&lt;/span&gt;;&lt;br /&gt;b = &lt;span class="kw4"&gt;record&lt;/span&gt;&lt;br /&gt;      x: &lt;span class="kw4"&gt;Integer&lt;/span&gt;;&lt;br /&gt;      y: &lt;span class="kw4"&gt;Char&lt;/span&gt;&lt;br /&gt;    &lt;span class="kw1"&gt;end&lt;/span&gt;;&lt;br /&gt;c = &lt;span class="kw4"&gt;File&lt;/span&gt; &lt;span class="kw1"&gt;of&lt;/span&gt; a;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;As shown in the example above, Pascal &lt;a href="http://en.wikipedia.org/wiki/Computer_file" title="Computer file"&gt;files&lt;/a&gt; are sequences of components. Every file has a buffer variable which is denoted by &lt;i&gt;f^&lt;/i&gt;. The procedures &lt;i&gt;get&lt;/i&gt; (for reading) and &lt;i&gt;put&lt;/i&gt; (for writing) move the buffer variable to the next element. Read is introduced such that &lt;i&gt;read(f, x)&lt;/i&gt; is the same as &lt;i&gt;x:=f^; get(f);&lt;/i&gt;. Write is introduced such that &lt;i&gt;write(f, x)&lt;/i&gt; is the same as &lt;i&gt;f^ := x; put(f);&lt;/i&gt; The type text is predefined as file of char. While the buffer variable could be used to inspect the next character that would be used (check for a digit before reading an integer), this concept lead to serious problems with interactive programs with early implementations, but was solved later with the "lazy I/O" concept.&lt;/p&gt; &lt;p&gt;In Jensen &amp;amp; Wirth Pascal, strings are represented as packed arrays of chars; they therefore have fixed length and are usually space-padded. Some dialects have a custom string type.&lt;/p&gt;</description></item><item><title>Implementations Pascal</title><link>http://pascalprog.blogspot.com/2007/11/implementations-pascal.html</link><category>Basic</category><category>CDC 600</category><category>compiler pascal</category><category>GNU pascal</category><category>ICL 1900</category><category>Implementations</category><category>IP Pascal</category><category>MPW</category><category>Object Pascal</category><category>PDP-100UCSD p-system</category><category>Super pascal</category><category>turbo pascal</category><author>noreply@blogger.com (dazchild)</author><pubDate>Sat, 24 Nov 2007 01:40:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-8817099320912405065.post-966981235578577501</guid><description>&lt;p&gt;The first Pascal &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compiler&lt;/a&gt; was designed in &lt;a href="http://en.wikipedia.org/wiki/Zurich" title="Zurich"&gt;Zurich&lt;/a&gt; for the &lt;a href="http://en.wikipedia.org/wiki/CDC_6000_series" title="CDC 6000 series"&gt;CDC 6000 series&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Mainframe_computer" title="Mainframe computer"&gt;mainframe computer&lt;/a&gt; family. Niklaus Wirth reports that a first attempt to implement it in &lt;a href="http://en.wikipedia.org/wiki/Fortran" title="Fortran"&gt;Fortran&lt;/a&gt; in &lt;a href="http://en.wikipedia.org/wiki/1969" title="1969"&gt;1969&lt;/a&gt; was unsuccessful due to Fortran's inadequacy to express complex data structures. The second attempt was formulated in the Pascal language itself and was operational by mid-&lt;a href="http://en.wikipedia.org/wiki/1970" title="1970"&gt;1970&lt;/a&gt;. Many Pascal compilers since have been similarly &lt;a href="http://en.wikipedia.org/wiki/Self-hosting" title="Self-hosting"&gt;self-hosting&lt;/a&gt;, that is, the compiler is itself written in Pascal, and the compiler is usually capable of recompiling itself when new features are added to the language, or when the compiler is to be &lt;a href="http://en.wikipedia.org/wiki/Porting" title="Porting"&gt;ported&lt;/a&gt; to a new environment. The &lt;a href="http://en.wikipedia.org/wiki/GNU_Pascal" title="GNU Pascal"&gt;GNU Pascal&lt;/a&gt; compiler is one notable exception, being written in C.&lt;/p&gt; &lt;p&gt;The first successful port of the CDC Pascal compiler to another mainframe was completed by Welsh and Quinn at the &lt;a href="http://en.wikipedia.org/wiki/Queen%27s_University_of_Belfast" title="Queen's University of Belfast"&gt;Queen's University of Belfast&lt;/a&gt; in &lt;a href="http://en.wikipedia.org/wiki/1972" title="1972"&gt;1972&lt;/a&gt;. The target was the &lt;a href="http://en.wikipedia.org/wiki/International_Computers_Ltd" title="International Computers Ltd"&gt;ICL&lt;/a&gt; 1900 computer.&lt;/p&gt; &lt;p&gt;The first Pascal &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compiler&lt;/a&gt; written in North America was constructed at the &lt;a href="http://en.wikipedia.org/wiki/University_of_Illinois_at_Urbana-Champaign" title="University of Illinois at Urbana-Champaign"&gt;University of Illinois&lt;/a&gt; under &lt;a href="http://en.wikipedia.org/wiki/Donald_B._Gillies#Later_Career" title="Donald B. Gillies"&gt;Donald B. Gillies&lt;/a&gt; for the &lt;a href="http://en.wikipedia.org/wiki/PDP-11" title="PDP-11"&gt;PDP-11&lt;/a&gt; and generated native machine code. Pascal enjoyed great popularity throughout the 1970s and the 1980s.&lt;/p&gt; &lt;p&gt;In order to rapidly propagate the language, a compiler "porting kit" was created in Zurich that included a compiler that generated code for a "virtual" stack machine (i.e. code that lends itself to reasonably efficient interpretation), along with an interpreter for that code - the &lt;i&gt;p-code&lt;/i&gt; system. Although the p-code was primarily intended to be compiled into true machine code, at least one system, the notable UCSD implementation, utilized it to create the &lt;a href="http://en.wikipedia.org/wiki/Interpreter_%28computing%29" title="Interpreter (computing)"&gt;interpretive&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/UCSD_p-System" title="UCSD p-System"&gt;UCSD p-System&lt;/a&gt;. The P-system compilers were termed P1-P4, with P1 being the first version, and P4 being the last.&lt;/p&gt; &lt;p&gt;A version of the P4 compiler, which created native binaries, was released for the &lt;a href="http://en.wikipedia.org/wiki/IBM_System/370" title="IBM System/370"&gt;IBM System/370&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Mainframe_computer" title="Mainframe computer"&gt;mainframe computer&lt;/a&gt; by the &lt;a href="http://en.wikipedia.org/wiki/Australian_Atomic_Energy_Commission" title="Australian Atomic Energy Commission"&gt;Australian Atomic Energy Commission&lt;/a&gt;; it was called the "AAEC Pascal Compiler" after the abbreviation of the name of the Commission. A version of P4 from &lt;a href="http://en.wikipedia.org/wiki/1975" title="1975"&gt;1975&lt;/a&gt;-6 (based on its internal code, it probably should be called "P5") including source and binaries for the compiler and run-time library files for the &lt;a href="http://en.wikipedia.org/wiki/PDP-10" title="PDP-10"&gt;PDP-10&lt;/a&gt; mainframe may be downloaded from &lt;a href="ftp://pdp-10.trailing-edge.com/pub/pdp10freewarev2/lib20/0003/" class="external text" title="ftp://pdp-10.trailing-edge.com/pub/pdp10freewarev2/lib20/0003/" rel="nofollow"&gt;this link&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;In the early &lt;a href="http://en.wikipedia.org/wiki/1980s" title="1980s"&gt;1980s&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Watcom" title="Watcom"&gt;Watcom&lt;/a&gt; Pascal was developed, also for the IBM &lt;a href="http://en.wikipedia.org/wiki/System_370" title="System 370"&gt;System 370&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/IP_Pascal" title="IP Pascal"&gt;IP Pascal&lt;/a&gt; was an implementation of the Pascal programming language using Micropolis DOS, but was moved rapidly to CP/M running on the &lt;a href="http://en.wikipedia.org/wiki/Zilog_Z80" title="Zilog Z80"&gt;Z80&lt;/a&gt;. It was moved to the 80386 machine types in 1994, and exists today as Windows/XP and Linux implementations.&lt;/p&gt; &lt;p&gt;In the early &lt;a href="http://en.wikipedia.org/wiki/1980s" title="1980s"&gt;1980s&lt;/a&gt;, UCSD Pascal was ported to the &lt;a href="http://en.wikipedia.org/wiki/Apple_II" title="Apple II"&gt;Apple II&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Apple_III" title="Apple III"&gt;Apple III&lt;/a&gt; computers to provide a structured alternative to the &lt;a href="http://en.wikipedia.org/wiki/BASIC" title="BASIC"&gt;BASIC&lt;/a&gt; interpreters that came with the machines.&lt;/p&gt; &lt;p&gt;Apple Computer created its own Lisa Pascal for the Lisa Workshop in 1982 and ported this compiler to the Apple Macintosh and &lt;a href="http://en.wikipedia.org/wiki/MPW" title="MPW"&gt;MPW&lt;/a&gt; in 1985. In 1985 Larry Tesler, in consultation with Niklaus Wirth, defined Object Pascal and these extensions were incorporated in both the Lisa Pascal and Mac Pascal compilers.&lt;/p&gt; &lt;p&gt;In the &lt;a href="http://en.wikipedia.org/wiki/1980s" title="1980s"&gt;1980s&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Anders_Hejlsberg" title="Anders Hejlsberg"&gt;Anders Hejlsberg&lt;/a&gt; wrote the Blue Label Pascal compiler for the &lt;a href="http://en.wikipedia.org/wiki/Nascom" title="Nascom"&gt;Nascom-2&lt;/a&gt;. A reimplementation of this compiler for the &lt;a href="http://en.wikipedia.org/wiki/IBM_PC" title="IBM PC"&gt;IBM PC&lt;/a&gt; was marketed under the names Compas Pascal and PolyPascal before it was acquired by &lt;a href="http://en.wikipedia.org/wiki/Borland" title="Borland"&gt;Borland&lt;/a&gt;. Renamed to &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Turbo_Pascal" title="Turbo Pascal"&gt;Turbo Pascal&lt;/a&gt;&lt;/i&gt; it became hugely popular, thanks in part to an aggressive pricing strategy and in part to having one of the first full-screen &lt;a href="http://en.wikipedia.org/wiki/Integrated_development_environment" title="Integrated development environment"&gt;Integrated development environments&lt;/a&gt;. Additionally, it was written and highly optimized entirely in &lt;a href="http://en.wikipedia.org/wiki/Assembly_language" title="Assembly language"&gt;assembly language&lt;/a&gt;, making it &lt;a href="http://en.wikipedia.org/wiki/Memory_footprint" title="Memory footprint"&gt;smaller&lt;/a&gt; and faster than much of the competition. In &lt;a href="http://en.wikipedia.org/wiki/1986" title="1986"&gt;1986&lt;/a&gt; Anders ported Turbo Pascal to the Macintosh and incorporated Apple's Object Pascal extensions into Turbo Pascal. These extensions were then added back into the PC version of Turbo Pascal for version 5.5.&lt;/p&gt; &lt;p&gt;The inexpensive Borland compiler had a large influence on the Pascal community that began concentrating mainly on the IBM PC in the late 1980s. Many PC hobbyists in search of a structured replacement for &lt;a href="http://en.wikipedia.org/wiki/BASIC_programming_language" title="BASIC programming language"&gt;BASIC&lt;/a&gt; used this product. It also began adoption by professional developers. Around the same time a number of concepts were imported from &lt;a href="http://en.wikipedia.org/wiki/C_%28programming_language%29" title="C (programming language)"&gt;C&lt;/a&gt; in order to let Pascal programmers use the C-based &lt;a href="http://en.wikipedia.org/wiki/Application_programming_interface" title="Application programming interface"&gt;API&lt;/a&gt; of &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Windows" title="Microsoft Windows"&gt;Microsoft Windows&lt;/a&gt; directly. These extensions included null-terminated &lt;a href="http://en.wikipedia.org/wiki/String_%28computer_science%29" title="String (computer science)"&gt;strings&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Pointer_arithmetic" title="Pointer arithmetic"&gt;pointer arithmetic&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Function_pointer" title="Function pointer"&gt;function pointers&lt;/a&gt;, an address-of operator and unsafe &lt;a href="http://en.wikipedia.org/wiki/Type_conversion" title="Type conversion"&gt;typecasts&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;However, Borland later decided it wanted more elaborate object-oriented features, and started over in Delphi using the &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Object_Pascal" title="Object Pascal"&gt;Object Pascal&lt;/a&gt;&lt;/i&gt; draft standard proposed by &lt;a href="http://en.wikipedia.org/wiki/Apple_Computer" title="Apple Computer"&gt;Apple&lt;/a&gt; as a basis. (This Apple draft is still not a formal standard.) Borland also called this &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Object_Pascal" title="Object Pascal"&gt;Object Pascal&lt;/a&gt;&lt;/i&gt; in the first Delphi versions, but changed the name to Delphi Programming Language in later versions. The main additions compared to the older OOP extensions were a reference-based object model, virtual constructors and destructors, and properties. There are several other compilers implementing this dialect, see &lt;a href="http://en.wikipedia.org/wiki/Object_Pascal" title="Object Pascal"&gt;Object Pascal&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Turbo_Pascal" title="Turbo Pascal"&gt;Turbo Pascal&lt;/a&gt;, and other derivatives with units or module concepts are &lt;a href="http://en.wikipedia.org/wiki/Modularity_%28programming%29" title="Modularity (programming)"&gt;modular languages&lt;/a&gt;. However, it does not provide a nested module concept or qualified import and export of specific symbols.&lt;/p&gt; &lt;p&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Super_Pascal&amp;amp;action=edit" class="new" title="Super Pascal"&gt;Super Pascal&lt;/a&gt; was a variant which added non-numeric labels, a return statement and expressions as names of types.&lt;/p&gt; &lt;p&gt;The universities of &lt;a href="http://en.wikipedia.org/wiki/Zurich" title="Zurich"&gt;Zurich&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Karlsruhe" title="Karlsruhe"&gt;Karlsruhe&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Wuppertal" title="Wuppertal"&gt;Wuppertal&lt;/a&gt; have developed an &lt;i&gt;E&lt;b&gt;X&lt;/b&gt;tension for &lt;b&gt;S&lt;/b&gt;cientific &lt;b&gt;C&lt;/b&gt;omputing&lt;/i&gt; (Pascal XSC), which provides a free solution for programming numerical computations with controlled precision.&lt;/p&gt; &lt;p&gt;In &lt;a href="http://en.wikipedia.org/wiki/2005" title="2005"&gt;2005&lt;/a&gt;, at the Web 2.0 conference, &lt;a href="http://en.wikipedia.org/wiki/Morfik" title="Morfik"&gt;Morfik&lt;/a&gt; Technology introduced a tool which allowed the development of Web applications entirely written in Morfik Pascal. Morfik Pascal is a dialect of Object Pascal, very close to Delphi.&lt;/p&gt;</description></item></channel></rss>