[{"data":1,"prerenderedAt":323},["ShallowReactive",2],{"tag-labels":3,"site-header":4,"article-pascal-dynamic-array-en":72},{},{"featuredPost":5,"navigations":29},{"id":6,"title":7,"title_id":8,"slug":9,"excerpt":10,"excerpt_id":11,"has_translation":12,"published_at":13,"reading_time":14,"hidden_from_listing":15,"tags":16,"thumbnail_image":21,"og_image":22,"series":23,"authors":28},110,"When You Pick a Framework Just to Look Different","Ketika Pilih Framework Cuma Biar Kelihatan Beda","ketika-pilih-framework-cuma-biar-kelihatan-beda","The last time you chose a new framework or library, was it because your problem needed that tool, or because it sounded cool and few people around you were using it? That question is uncomfortable. Technology decisions are often made for reasons that never appear in any technical document.","Terakhir kali kamu milih framework atau library baru, itu karena masalahmu butuh alat itu, atau karena alatnya kedengaran keren dan belum banyak yang pakai? Pertanyaan ini nggak enak dijawab. Soalnya keputusan teknologi sering diambil dengan alasan yang nggak pernah ditulis di dokumen teknis mana pun.",true,"2026-10-06T15:25:21.000Z",5,false,[17,18,19,20],"karier","framework","opini","pengalaman",null,"\u002Fog\u002Fketika-pilih-framework-cuma-biar-kelihatan-beda.png",{"id":24,"title":25,"title_id":26,"slug":27},9,"Articles","Artikel","all",[],[30,46,67],{"collection":31,"item":32},"series",{"__typename":31,"title":25,"title_id":26,"slug":27,"children_series":33},[34,38,42],{"title":35,"title_id":36,"slug":37},"Artificial Intelligence","Kecerdasan Artifisial","kecerdasan-artifisial",{"title":39,"title_id":40,"slug":41},"Programming Fundamentals","Konsep Dasar Pemrograman","konsep-dasar-pemrograman",{"title":43,"title_id":44,"slug":45},"Algorithms and Data Structures","Algoritma dan Struktur Data","algoritma-struktur-data",{"collection":31,"item":47},{"__typename":31,"title":48,"title_id":48,"slug":49,"children_series":50},"Tutorial","tutorial",[51,55,59,63],{"title":52,"title_id":53,"slug":54},"Learning Python","Belajar Python","belajar-python",{"title":56,"title_id":57,"slug":58},"Learning Go","Belajar Golang","belajar-golang",{"title":60,"title_id":61,"slug":62},"Learning Java","Belajar Java","belajar-java",{"title":64,"title_id":65,"slug":66},"Learning Pascal","Belajar Pascal","belajar-pascal",{"collection":31,"item":68},{"__typename":31,"title":69,"title_id":69,"slug":70,"children_series":71},"Lab","lab",[],{"article":73,"renderedBody":197,"renderedTakeaway":198,"latestArticles":199,"toc":304},{"id":74,"title":75,"title_id":76,"slug":77,"excerpt":78,"excerpt_id":79,"has_translation":12,"published_at":80,"reading_time":81,"hidden_from_listing":15,"tags":82,"thumbnail_image":21,"og_image":86,"series":87,"authors":188,"seoTitle":21,"seoDescription":21,"body_locale":191,"available_locales":192,"body":194,"takeway":195,"prerequisite":196},147,"Pascal Dynamic Arrays: the Sixth Score That Never Got Counted","Array Dinamis Pascal: Nilai Keenam yang Tidak Pernah Ikut Terhitung","pascal-dynamic-array","Six scores go in, five get counted, and the mean prints 78.0 because a fixed array stopped reading at MAX. `SetLength` gives the array the length the data asks for, and it also changes what assignment means.","Enam nilai masuk, lima yang terhitung, dan rata-ratanya tercetak 78.0 karena array tetap berhenti membaca di MAX. `SetLength` memberi array panjang yang diminta datanya, dan ia juga mengubah arti penugasan.","2026-11-11T01:00:00.000Z",8,[83,84,85],"pascal","array","tipe-data","\u002Fog\u002Fpascal-dynamic-array.png",{"id":88,"title":89,"title_id":90,"slug":91,"description":92,"description_id":93,"articles":94,"children_series":167,"parent_series":168},25,"Composite Types","Tipe Data Bentukan","pascal-tipe-data-bentukan","Types you build yourself: record, array, and the pointer that keeps confusing everyone at first.","Tipe data racikan sendiri: record, array, sampai pointer yang sering bikin pusing di awal.",[95,116,131,146,162],{"id":96,"title":97,"title_id":98,"slug":99,"excerpt":100,"excerpt_id":101,"has_translation":12,"published_at":102,"reading_time":103,"hidden_from_listing":15,"tags":104,"thumbnail_image":21,"og_image":107,"series":108,"authors":109},73,"User-Defined Data Types in Pascal","Tentang Tipe Data Bentukan pada Pascal","tentang-tipe-data-bentukan-pada-pascal","User-defined data types in Pascal come in 2 kinds, Enumerated and Subrange, and you declare both of them yourself.","Tipe data bentukan atau User defined data types terbagi menjadi 2, yaitu Enumerated dan Subrange","2020-11-22T13:49:03.000Z",3,[83,85,105,106],"struktur-data","konsep","\u002Fog\u002Ftentang-tipe-data-bentukan-pada-pascal.png",{"id":88,"title":89,"title_id":90,"slug":91},[110],{"authors_id":111},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},1,"Daffa Izzuddin","izzudd","Writer",{"id":117,"title":118,"title_id":119,"slug":120,"excerpt":121,"excerpt_id":122,"has_translation":12,"published_at":123,"reading_time":103,"hidden_from_listing":15,"tags":124,"thumbnail_image":21,"og_image":126,"series":127,"authors":128},74,"Using the RECORD Data Type in Pascal","Menggunakan Tipe Data RECORD pada Pascal","menggunakan-tipe-data-record-pada-pascal","RECORD is a structured data type in Pascal, built from a collection of standard and user-defined data types.","RECORD merupakan tipe data terstruktur pada bahasa Pascal yang terdiri dari kumpulan tipe data standar dan bentukan.","2020-11-27T13:54:30.000Z",[83,125,85,105],"record","\u002Fog\u002Fmenggunakan-tipe-data-record-pada-pascal.png",{"id":88,"title":89,"title_id":90,"slug":91},[129],{"authors_id":130},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":132,"title":133,"title_id":134,"slug":135,"excerpt":136,"excerpt_id":137,"has_translation":12,"published_at":138,"reading_time":139,"hidden_from_listing":15,"tags":140,"thumbnail_image":21,"og_image":141,"series":142,"authors":143},75,"Using the Array Data Type in Pascal","Menggunakan Tipe Data Array pada Pascal","menggunakan-tipe-data-array-pada-pascal","An ARRAY is a structure that holds a set of data with the same type, and you reach each item in it through its index.","ARRAY merupakan struktur data yang berisi sekumpulan data dengan tipe data yang sama. Data dalam ARRAY ini dapat diakses dengan menggunakan index.","2020-12-02T14:01:22.000Z",4,[83,84,85,105],"\u002Fog\u002Fmenggunakan-tipe-data-array-pada-pascal.png",{"id":88,"title":89,"title_id":90,"slug":91},[144],{"authors_id":145},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":147,"title":148,"title_id":149,"slug":150,"excerpt":151,"excerpt_id":152,"has_translation":12,"published_at":153,"reading_time":154,"hidden_from_listing":15,"tags":155,"thumbnail_image":21,"og_image":157,"series":158,"authors":159},76,"Using Pointers in Pascal","Menggunakan Pointer pada Bahasa Pascal","menggunakan-pointer-pada-bahasa-pascal","A variable of pointer type can only hold the address of another variable, and changing it changes that other variable.","Sebuah variable yang bertipe pointer nantinya hanya dapat berisi sebuah alamat dari variable lain.","2020-12-02T14:17:47.000Z",2,[83,156,85,106],"pointer","\u002Fog\u002Fmenggunakan-pointer-pada-bahasa-pascal.png",{"id":88,"title":89,"title_id":90,"slug":91},[160],{"authors_id":161},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":74,"title":75,"title_id":76,"slug":77,"excerpt":78,"excerpt_id":79,"has_translation":12,"published_at":80,"reading_time":81,"hidden_from_listing":15,"tags":82,"thumbnail_image":21,"og_image":86,"series":163,"authors":164},{"id":88,"title":89,"title_id":90,"slug":91},[165],{"authors_id":166},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},[],{"id":169,"title":64,"title_id":65,"slug":66,"parent_series":170,"children_series":171},14,{"id":112,"title":48,"title_id":48,"slug":49},[172,177,182,183],{"id":173,"title":174,"title_id":175,"slug":176,"cover_image":21},23,"Getting Started with Pascal","Berkenalan dengan Bahasa Pascal","pascal-intro",{"id":178,"title":179,"title_id":180,"slug":181,"cover_image":21},24,"Control Structures","Struktur Kontrol","pascal-struktur-kontrol",{"id":88,"title":89,"title_id":90,"slug":91,"cover_image":21},{"id":184,"title":185,"title_id":186,"slug":187,"cover_image":21},26,"Procedural Programming","Pemrograman Prosedural","pascal-pemrograman-prosedural",[189],{"authors_id":190},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},"en",[191,193],"id","\nYou feed a program six scores and it reports five. The file `scores.txt` holds 72, 85, 91, 64, 78 and 67, one per line. The program prints a count of 5 and a mean of 78.0, with no crash and no warning. The true mean is 76.2, which is 457 divided by 6.\n\n```pascal\nprogram average;\n\n{ Version 1: a fixed array of five, and a sixth score that never lands. }\n\nconst\n  MAX = 5;\n\nvar\n  scores: array[1..MAX] of integer;\n  n, i, sum: integer;\n\nbegin\n  n := 0;\n  sum := 0;\n  for i := 1 to MAX do\n    if not eof then\n    begin\n      readln(scores[i]);\n      n := n + 1;\n      sum := sum + scores[i];\n    end;\n  writeln('count: ', n);\n  writeln('mean: ', sum \u002F n:0:1);\nend.\n```\n\n```plain\n$ fpc average.pas && .\u002Faverage \u003C scores.txt\ncount: 5\nmean: 78.0\n```\n\nThe constant `MAX` stopped the `for` loop after five reads, and the sixth line stayed unread in the file. A static array has its size fixed when you write the program, and the loop obeys that size without complaint. Nothing in the file or the compiler flags the missing line, so the only way to catch it is to compare the output with the answer you expect.\n\n## Give the array a length at run time\n\nA dynamic array is declared as `array of integer`, with no bounds. The variable starts empty: its `Length` is 0 and it equals `nil`, the pointer value that refers to nothing. `SetLength` gives it a size.\n\n```pascal\nprogram explore;\n\nvar\n  a, b: array of integer;\n  i: integer;\n\nbegin\n  writeln('before SetLength: Length = ', Length(a), ', a = nil is ', a = nil);\n  SetLength(a, 3);\n  writeln('after SetLength(a, 3): Length = ', Length(a), ', Low = ', Low(a), ', High = ', High(a));\n  write('elements:');\n  for i := Low(a) to High(a) do\n    write(' ', a[i]);\n  writeln;\n  writeln('sizeof(a) = ', sizeof(a));\n  a[0] := 10;\n  a[1] := 20;\n  a[2] := 30;\n  SetLength(a, 5);\n  writeln('grown to 5: Length = ', Length(a), ', kept ', a[0], ' ', a[1], ' ', a[2], ', new ', a[3], ' ', a[4]);\n  b := a;\n  b[0] := 99;\n  writeln('b[0] = 99, a[0] = ', a[0], ', same storage = ', @b[0] = @a[0]);\n  SetLength(a, 0);\n  writeln('after SetLength(a, 0): Length = ', Length(a), ', a = nil is ', a = nil);\n  writeln('b is still ', Length(b), ' elements, b[0] = ', b[0]);\nend.\n```\n\n```plain\n$ fpc explore.pas && .\u002Fexplore\nbefore SetLength: Length = 0, a = nil is TRUE\nafter SetLength(a, 3): Length = 3, Low = 0, High = 2\nelements: 0 0 0\nsizeof(a) = 8\ngrown to 5: Length = 5, kept 10 20 30, new 0 0\nb[0] = 99, a[0] = 99, same storage = TRUE\nafter SetLength(a, 0): Length = 0, a = nil is TRUE\nb is still 5 elements, b[0] = 99\n```\n\nThe indexes run from 0 to 2, where `array[1..5]` runs from 1 to 5. New elements are zero, not leftover garbage. Growing from 3 to 5 keeps `10 20 30` and fills the two new slots with zeros.\n\n`sizeof(a)` is 8 whatever the length, because the variable holds a pointer to the data and not the data. A static `array[1..5] of integer` occupies 10 bytes here: five integers of two bytes each, Free Pascal's default size. The dynamic version replaces those 10 bytes with an 8-byte pointer plus a heap block, which is memory the program requests while it runs.\n\n## Two names, one array\n\nThe assignment `b := a` copies the pointer, not the elements. After `b[0] := 99`, `a[0]` reads 99 too, and `@b[0] = @a[0]` is TRUE: both names reach the same storage. `SetLength(a, 0)` empties `a`, yet `b` still holds its five elements. Pascal counts references to the block and frees it when the last one goes.\n\n`Copy` gives you independent storage. `Copy(a, 1, 3)` on an array holding `3 4 5 6 7 8` returns `4 5 6`, because the start index is 0-based like the array itself. `Copy(a, 4, 3)` returns only `7 8`, because only two elements were left. Changing the copy's first element to 999 left the original at 3, and `@original[0] = @copy[0]` was FALSE.\n\n## The exception: nothing guards the end\n\n```pascal\nprogram probe4;\n\n{ Out-of-bounds with an index the compiler cannot see. }\n\nvar\n  dyn: array of integer;\n  i: integer;\n\nbegin\n  SetLength(dyn, 3);\n  i := Length(dyn);\n  writeln('writing at index ', i, ' of length ', Length(dyn));\n  dyn[i] := 42;\n  writeln('survived, dyn[i] = ', dyn[i]);\nend.\n```\n\n```plain\n$ fpc probe4.pas && .\u002Fprobe4\nwriting at index 3 of length 3\nsurvived, dyn[i] = 42\n```\n\nIndex 3 on a length-3 array writes into memory the array does not own, and the program exits with status 0. Range checking is off by default. Build with `-Cr` and the same write stops the program:\n\n```plain\n$ fpc -Cr probe4.pas && .\u002Fprobe4\nwriting at index 3 of length 3\nRuntime error 201 at $00000000004011D9\n  $00000000004011D9\n  $000000000042308C\n```\n\nThe exit status is 201. A constant index is caught earlier: with `-Cr`, writing index 4 into a fixed `array[1..3]` stops compilation with `Error: range check error while evaluating constants (4 must be between 1 and 3)`.\n\n## Make the check fail first\n\nSave this as `check_average.pas`. It reads a program's output on stdin and compares it to two expected lines. For each line it prints PASS or FAIL, and a line that never arrives counts as a failure with the note \"no such line\".\n\n```pascal\nprogram check_average;\n\n{ Reads the program's output on stdin and compares it to the expected lines. }\n\nvar\n  expected: array[1..2] of string;\n  line: string;\n  i, passed, failed, total: integer;\n\nprocedure Report(ok: boolean; n: integer; want, got: string);\nbegin\n  if ok then\n  begin\n    writeln('PASS  line ', n, ': ', want);\n    passed := passed + 1;\n  end\n  else\n  begin\n    if got = '' then\n      writeln('FAIL  line ', n, ': expected \"', want, '\", no such line')\n    else\n      writeln('FAIL  line ', n, ': expected \"', want, '\", got \"', got, '\"');\n    failed := failed + 1;\n  end;\nend;\n\nbegin\n  expected[1] := 'count: 6';\n  expected[2] := 'mean: 76.2';\n\n  passed := 0;\n  failed := 0;\n  total := 2;\n  i := 0;\n\n  while (not eof) and (i \u003C total) do\n  begin\n    readln(line);\n    i := i + 1;\n    Report(line = expected[i], i, expected[i], line);\n  end;\n\n  while i \u003C total do\n  begin\n    i := i + 1;\n    Report(false, i, expected[i], '');\n  end;\n\n  writeln;\n  writeln(passed, ' of ', total, ' checks passed');\n  if failed > 0 then\n    ExitCode := 1;\nend.\n```\n\nCompile the checker and version 1 of `average.pas` with `fpc`, then pipe one into the other.\n\n```plain\n$ .\u002Faverage \u003C scores.txt | .\u002Fcheck_average\nFAIL  line 1: expected \"count: 6\", got \"count: 5\"\nFAIL  line 2: expected \"mean: 76.2\", got \"mean: 78.0\"\n\n0 of 2 checks passed\n```\n\nThe checker exits with status 1 here, so a script can gate on it.\n\n## Switch to a dynamic array\n\nReplace `average.pas` with version 2. The fixed array becomes `array of integer`, and `SetLength(scores, n + 1)` runs before each read.\n\n```pascal\nprogram average;\n\n{ Version 2: the array grows to fit whatever arrives. }\n\nvar\n  scores: array of integer;\n  n, sum: integer;\n\nbegin\n  n := 0;\n  sum := 0;\n  while not eof do\n  begin\n    SetLength(scores, n + 1);\n    readln(scores[n]);\n    sum := sum + scores[n];\n    n := n + 1;\n  end;\n  writeln('count: ', Length(scores));\n  writeln('mean: ', sum \u002F n:0:1);\nend.\n```\n\nCompile it and run the same pipe.\n\n```plain\n$ .\u002Faverage \u003C scores.txt | .\u002Fcheck_average\nPASS  line 1: count: 6\nPASS  line 2: mean: 76.2\n\n2 of 2 checks passed\n```\n\nThe checker now exits with status 0. Version 2 reports `Length(scores)` as its count, so the number comes from the array itself. The loop has no `MAX` to stop it, and the array ends up as long as the file.\n\n## Choosing between them\n\nAsk who decides the count. If you decide it when you write the program, use `array[1..N]` with a constant. If the data decides it, use `array of` and index from 0. Build with `-Cr` while you test, because a dynamic array does not stop a write past its end by default.\n","- A fixed `array[1..MAX]` stops reading at `MAX` without a warning, which is how six scores produced the mean of five.\n- A dynamic array starts with `Length` 0 and equal to `nil`; `SetLength` gives it a length, and the new elements arrive as zero, not as garbage.\n- Its indexes run from 0 to `High`, where a static `array[1..5]` runs from 1 to 5.\n- `b := a` copies the pointer, so writing through `b` changes `a`; `Copy(a, start, count)` is what makes independent storage.\n- `SetLength(a, 0)` releases what `a` points at, but a second variable holding the same block keeps the data alive until the last reference goes.\n- Nothing stops a write past the end by default: build with `-Cr` to turn it into `Runtime error 201` instead of silent corruption.",{"id":132,"title":133,"slug":135},"\u003Cp>You feed a program six scores and it reports five. The file \u003Ccode>scores.txt\u003C\u002Fcode> holds 72, 85, 91, 64, 78 and 67, one per line. The program prints a count of 5 and a mean of 78.0, with no crash and no warning. The true mean is 76.2, which is 457 divided by 6.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20average%3B%0A%0A%7B%20Version%201%3A%20a%20fixed%20array%20of%20five%2C%20and%20a%20sixth%20score%20that%20never%20lands.%20%7D%0A%0Aconst%0A%20%20MAX%20%3D%205%3B%0A%0Avar%0A%20%20scores%3A%20array%5B1..MAX%5D%20of%20integer%3B%0A%20%20n%2C%20i%2C%20sum%3A%20integer%3B%0A%0Abegin%0A%20%20n%20%3A%3D%200%3B%0A%20%20sum%20%3A%3D%200%3B%0A%20%20for%20i%20%3A%3D%201%20to%20MAX%20do%0A%20%20%20%20if%20not%20eof%20then%0A%20%20%20%20begin%0A%20%20%20%20%20%20readln(scores%5Bi%5D)%3B%0A%20%20%20%20%20%20n%20%3A%3D%20n%20%2B%201%3B%0A%20%20%20%20%20%20sum%20%3A%3D%20sum%20%2B%20scores%5Bi%5D%3B%0A%20%20%20%20end%3B%0A%20%20writeln('count%3A%20'%2C%20n)%3B%0A%20%20writeln('mean%3A%20'%2C%20sum%20%2F%20n%3A0%3A1)%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program average;\n\n{ Version 1: a fixed array of five, and a sixth score that never lands. }\n\nconst\n  MAX = 5;\n\nvar\n  scores: array[1..MAX] of integer;\n  n, i, sum: integer;\n\nbegin\n  n := 0;\n  sum := 0;\n  for i := 1 to MAX do\n    if not eof then\n    begin\n      readln(scores[i]);\n      n := n + 1;\n      sum := sum + scores[i];\n    end;\n  writeln('count: ', n);\n  writeln('mean: ', sum \u002F n:0:1);\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20average.pas%20%26%26%20.%2Faverage%20%3C%20scores.txt%0Acount%3A%205%0Amean%3A%2078.0\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc average.pas &amp;&amp; .\u002Faverage &lt; scores.txt\u003C\u002Fspan>\ncount: 5\nmean: 78.0\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The constant \u003Ccode>MAX\u003C\u002Fcode> stopped the \u003Ccode>for\u003C\u002Fcode> loop after five reads, and the sixth line stayed unread in the file. A static array has its size fixed when you write the program, and the loop obeys that size without complaint. Nothing in the file or the compiler flags the missing line, so the only way to catch it is to compare the output with the answer you expect.\u003C\u002Fp>\n\u003Ch2 id=\"give-the-array-a-length-at-run-time\">Give the array a length at run time\u003C\u002Fh2>\n\u003Cp>A dynamic array is declared as \u003Ccode>array of integer\u003C\u002Fcode>, with no bounds. The variable starts empty: its \u003Ccode>Length\u003C\u002Fcode> is 0 and it equals \u003Ccode>nil\u003C\u002Fcode>, the pointer value that refers to nothing. \u003Ccode>SetLength\u003C\u002Fcode> gives it a size.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20explore%3B%0A%0Avar%0A%20%20a%2C%20b%3A%20array%20of%20integer%3B%0A%20%20i%3A%20integer%3B%0A%0Abegin%0A%20%20writeln('before%20SetLength%3A%20Length%20%3D%20'%2C%20Length(a)%2C%20'%2C%20a%20%3D%20nil%20is%20'%2C%20a%20%3D%20nil)%3B%0A%20%20SetLength(a%2C%203)%3B%0A%20%20writeln('after%20SetLength(a%2C%203)%3A%20Length%20%3D%20'%2C%20Length(a)%2C%20'%2C%20Low%20%3D%20'%2C%20Low(a)%2C%20'%2C%20High%20%3D%20'%2C%20High(a))%3B%0A%20%20write('elements%3A')%3B%0A%20%20for%20i%20%3A%3D%20Low(a)%20to%20High(a)%20do%0A%20%20%20%20write('%20'%2C%20a%5Bi%5D)%3B%0A%20%20writeln%3B%0A%20%20writeln('sizeof(a)%20%3D%20'%2C%20sizeof(a))%3B%0A%20%20a%5B0%5D%20%3A%3D%2010%3B%0A%20%20a%5B1%5D%20%3A%3D%2020%3B%0A%20%20a%5B2%5D%20%3A%3D%2030%3B%0A%20%20SetLength(a%2C%205)%3B%0A%20%20writeln('grown%20to%205%3A%20Length%20%3D%20'%2C%20Length(a)%2C%20'%2C%20kept%20'%2C%20a%5B0%5D%2C%20'%20'%2C%20a%5B1%5D%2C%20'%20'%2C%20a%5B2%5D%2C%20'%2C%20new%20'%2C%20a%5B3%5D%2C%20'%20'%2C%20a%5B4%5D)%3B%0A%20%20b%20%3A%3D%20a%3B%0A%20%20b%5B0%5D%20%3A%3D%2099%3B%0A%20%20writeln('b%5B0%5D%20%3D%2099%2C%20a%5B0%5D%20%3D%20'%2C%20a%5B0%5D%2C%20'%2C%20same%20storage%20%3D%20'%2C%20%40b%5B0%5D%20%3D%20%40a%5B0%5D)%3B%0A%20%20SetLength(a%2C%200)%3B%0A%20%20writeln('after%20SetLength(a%2C%200)%3A%20Length%20%3D%20'%2C%20Length(a)%2C%20'%2C%20a%20%3D%20nil%20is%20'%2C%20a%20%3D%20nil)%3B%0A%20%20writeln('b%20is%20still%20'%2C%20Length(b)%2C%20'%20elements%2C%20b%5B0%5D%20%3D%20'%2C%20b%5B0%5D)%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program explore;\n\nvar\n  a, b: array of integer;\n  i: integer;\n\nbegin\n  writeln('before SetLength: Length = ', Length(a), ', a = nil is ', a = nil);\n  SetLength(a, 3);\n  writeln('after SetLength(a, 3): Length = ', Length(a), ', Low = ', Low(a), ', High = ', High(a));\n  write('elements:');\n  for i := Low(a) to High(a) do\n    write(' ', a[i]);\n  writeln;\n  writeln('sizeof(a) = ', sizeof(a));\n  a[0] := 10;\n  a[1] := 20;\n  a[2] := 30;\n  SetLength(a, 5);\n  writeln('grown to 5: Length = ', Length(a), ', kept ', a[0], ' ', a[1], ' ', a[2], ', new ', a[3], ' ', a[4]);\n  b := a;\n  b[0] := 99;\n  writeln('b[0] = 99, a[0] = ', a[0], ', same storage = ', @b[0] = @a[0]);\n  SetLength(a, 0);\n  writeln('after SetLength(a, 0): Length = ', Length(a), ', a = nil is ', a = nil);\n  writeln('b is still ', Length(b), ' elements, b[0] = ', b[0]);\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20explore.pas%20%26%26%20.%2Fexplore%0Abefore%20SetLength%3A%20Length%20%3D%200%2C%20a%20%3D%20nil%20is%20TRUE%0Aafter%20SetLength(a%2C%203)%3A%20Length%20%3D%203%2C%20Low%20%3D%200%2C%20High%20%3D%202%0Aelements%3A%200%200%200%0Asizeof(a)%20%3D%208%0Agrown%20to%205%3A%20Length%20%3D%205%2C%20kept%2010%2020%2030%2C%20new%200%200%0Ab%5B0%5D%20%3D%2099%2C%20a%5B0%5D%20%3D%2099%2C%20same%20storage%20%3D%20TRUE%0Aafter%20SetLength(a%2C%200)%3A%20Length%20%3D%200%2C%20a%20%3D%20nil%20is%20TRUE%0Ab%20is%20still%205%20elements%2C%20b%5B0%5D%20%3D%2099\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc explore.pas &amp;&amp; .\u002Fexplore\u003C\u002Fspan>\nbefore SetLength: Length = 0, a = nil is TRUE\nafter SetLength(a, 3): Length = 3, Low = 0, High = 2\nelements: 0 0 0\nsizeof(a) = 8\ngrown to 5: Length = 5, kept 10 20 30, new 0 0\nb[0] = 99, a[0] = 99, same storage = TRUE\nafter SetLength(a, 0): Length = 0, a = nil is TRUE\nb is still 5 elements, b[0] = 99\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The indexes run from 0 to 2, where \u003Ccode>array[1..5]\u003C\u002Fcode> runs from 1 to 5. New elements are zero, not leftover garbage. Growing from 3 to 5 keeps \u003Ccode>10 20 30\u003C\u002Fcode> and fills the two new slots with zeros.\u003C\u002Fp>\n\u003Cp>\u003Ccode>sizeof(a)\u003C\u002Fcode> is 8 whatever the length, because the variable holds a pointer to the data and not the data. A static \u003Ccode>array[1..5] of integer\u003C\u002Fcode> occupies 10 bytes here: five integers of two bytes each, Free Pascal&#39;s default size. The dynamic version replaces those 10 bytes with an 8-byte pointer plus a heap block, which is memory the program requests while it runs.\u003C\u002Fp>\n\u003Ch2 id=\"two-names-one-array\">Two names, one array\u003C\u002Fh2>\n\u003Cp>The assignment \u003Ccode>b := a\u003C\u002Fcode> copies the pointer, not the elements. After \u003Ccode>b[0] := 99\u003C\u002Fcode>, \u003Ccode>a[0]\u003C\u002Fcode> reads 99 too, and \u003Ccode>@b[0] = @a[0]\u003C\u002Fcode> is TRUE: both names reach the same storage. \u003Ccode>SetLength(a, 0)\u003C\u002Fcode> empties \u003Ccode>a\u003C\u002Fcode>, yet \u003Ccode>b\u003C\u002Fcode> still holds its five elements. Pascal counts references to the block and frees it when the last one goes.\u003C\u002Fp>\n\u003Cp>\u003Ccode>Copy\u003C\u002Fcode> gives you independent storage. \u003Ccode>Copy(a, 1, 3)\u003C\u002Fcode> on an array holding \u003Ccode>3 4 5 6 7 8\u003C\u002Fcode> returns \u003Ccode>4 5 6\u003C\u002Fcode>, because the start index is 0-based like the array itself. \u003Ccode>Copy(a, 4, 3)\u003C\u002Fcode> returns only \u003Ccode>7 8\u003C\u002Fcode>, because only two elements were left. Changing the copy&#39;s first element to 999 left the original at 3, and \u003Ccode>@original[0] = @copy[0]\u003C\u002Fcode> was FALSE.\u003C\u002Fp>\n\u003Ch2 id=\"the-exception-nothing-guards-the-end\">The exception: nothing guards the end\u003C\u002Fh2>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20probe4%3B%0A%0A%7B%20Out-of-bounds%20with%20an%20index%20the%20compiler%20cannot%20see.%20%7D%0A%0Avar%0A%20%20dyn%3A%20array%20of%20integer%3B%0A%20%20i%3A%20integer%3B%0A%0Abegin%0A%20%20SetLength(dyn%2C%203)%3B%0A%20%20i%20%3A%3D%20Length(dyn)%3B%0A%20%20writeln('writing%20at%20index%20'%2C%20i%2C%20'%20of%20length%20'%2C%20Length(dyn))%3B%0A%20%20dyn%5Bi%5D%20%3A%3D%2042%3B%0A%20%20writeln('survived%2C%20dyn%5Bi%5D%20%3D%20'%2C%20dyn%5Bi%5D)%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program probe4;\n\n{ Out-of-bounds with an index the compiler cannot see. }\n\nvar\n  dyn: array of integer;\n  i: integer;\n\nbegin\n  SetLength(dyn, 3);\n  i := Length(dyn);\n  writeln('writing at index ', i, ' of length ', Length(dyn));\n  dyn[i] := 42;\n  writeln('survived, dyn[i] = ', dyn[i]);\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20probe4.pas%20%26%26%20.%2Fprobe4%0Awriting%20at%20index%203%20of%20length%203%0Asurvived%2C%20dyn%5Bi%5D%20%3D%2042\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc probe4.pas &amp;&amp; .\u002Fprobe4\u003C\u002Fspan>\nwriting at index 3 of length 3\nsurvived, dyn[i] = 42\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Index 3 on a length-3 array writes into memory the array does not own, and the program exits with status 0. Range checking is off by default. Build with \u003Ccode>-Cr\u003C\u002Fcode> and the same write stops the program:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-Cr%20probe4.pas%20%26%26%20.%2Fprobe4%0Awriting%20at%20index%203%20of%20length%203%0ARuntime%20error%20201%20at%20%2400000000004011D9%0A%20%20%2400000000004011D9%0A%20%20%24000000000042308C\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -Cr probe4.pas &amp;&amp; .\u002Fprobe4\u003C\u002Fspan>\nwriting at index 3 of length 3\nRuntime error 201 at $00000000004011D9\n  $00000000004011D9\n  $000000000042308C\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The exit status is 201. A constant index is caught earlier: with \u003Ccode>-Cr\u003C\u002Fcode>, writing index 4 into a fixed \u003Ccode>array[1..3]\u003C\u002Fcode> stops compilation with \u003Ccode>Error: range check error while evaluating constants (4 must be between 1 and 3)\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ch2 id=\"make-the-check-fail-first\">Make the check fail first\u003C\u002Fh2>\n\u003Cp>Save this as \u003Ccode>check_average.pas\u003C\u002Fcode>. It reads a program&#39;s output on stdin and compares it to two expected lines. For each line it prints PASS or FAIL, and a line that never arrives counts as a failure with the note &quot;no such line&quot;.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20check_average%3B%0A%0A%7B%20Reads%20the%20program's%20output%20on%20stdin%20and%20compares%20it%20to%20the%20expected%20lines.%20%7D%0A%0Avar%0A%20%20expected%3A%20array%5B1..2%5D%20of%20string%3B%0A%20%20line%3A%20string%3B%0A%20%20i%2C%20passed%2C%20failed%2C%20total%3A%20integer%3B%0A%0Aprocedure%20Report(ok%3A%20boolean%3B%20n%3A%20integer%3B%20want%2C%20got%3A%20string)%3B%0Abegin%0A%20%20if%20ok%20then%0A%20%20begin%0A%20%20%20%20writeln('PASS%20%20line%20'%2C%20n%2C%20'%3A%20'%2C%20want)%3B%0A%20%20%20%20passed%20%3A%3D%20passed%20%2B%201%3B%0A%20%20end%0A%20%20else%0A%20%20begin%0A%20%20%20%20if%20got%20%3D%20''%20then%0A%20%20%20%20%20%20writeln('FAIL%20%20line%20'%2C%20n%2C%20'%3A%20expected%20%22'%2C%20want%2C%20'%22%2C%20no%20such%20line')%0A%20%20%20%20else%0A%20%20%20%20%20%20writeln('FAIL%20%20line%20'%2C%20n%2C%20'%3A%20expected%20%22'%2C%20want%2C%20'%22%2C%20got%20%22'%2C%20got%2C%20'%22')%3B%0A%20%20%20%20failed%20%3A%3D%20failed%20%2B%201%3B%0A%20%20end%3B%0Aend%3B%0A%0Abegin%0A%20%20expected%5B1%5D%20%3A%3D%20'count%3A%206'%3B%0A%20%20expected%5B2%5D%20%3A%3D%20'mean%3A%2076.2'%3B%0A%0A%20%20passed%20%3A%3D%200%3B%0A%20%20failed%20%3A%3D%200%3B%0A%20%20total%20%3A%3D%202%3B%0A%20%20i%20%3A%3D%200%3B%0A%0A%20%20while%20(not%20eof)%20and%20(i%20%3C%20total)%20do%0A%20%20begin%0A%20%20%20%20readln(line)%3B%0A%20%20%20%20i%20%3A%3D%20i%20%2B%201%3B%0A%20%20%20%20Report(line%20%3D%20expected%5Bi%5D%2C%20i%2C%20expected%5Bi%5D%2C%20line)%3B%0A%20%20end%3B%0A%0A%20%20while%20i%20%3C%20total%20do%0A%20%20begin%0A%20%20%20%20i%20%3A%3D%20i%20%2B%201%3B%0A%20%20%20%20Report(false%2C%20i%2C%20expected%5Bi%5D%2C%20'')%3B%0A%20%20end%3B%0A%0A%20%20writeln%3B%0A%20%20writeln(passed%2C%20'%20of%20'%2C%20total%2C%20'%20checks%20passed')%3B%0A%20%20if%20failed%20%3E%200%20then%0A%20%20%20%20ExitCode%20%3A%3D%201%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program check_average;\n\n{ Reads the program's output on stdin and compares it to the expected lines. }\n\nvar\n  expected: array[1..2] of string;\n  line: string;\n  i, passed, failed, total: integer;\n\nprocedure Report(ok: boolean; n: integer; want, got: string);\nbegin\n  if ok then\n  begin\n    writeln('PASS  line ', n, ': ', want);\n    passed := passed + 1;\n  end\n  else\n  begin\n    if got = '' then\n      writeln('FAIL  line ', n, ': expected \"', want, '\", no such line')\n    else\n      writeln('FAIL  line ', n, ': expected \"', want, '\", got \"', got, '\"');\n    failed := failed + 1;\n  end;\nend;\n\nbegin\n  expected[1] := 'count: 6';\n  expected[2] := 'mean: 76.2';\n\n  passed := 0;\n  failed := 0;\n  total := 2;\n  i := 0;\n\n  while (not eof) and (i &lt; total) do\n  begin\n    readln(line);\n    i := i + 1;\n    Report(line = expected[i], i, expected[i], line);\n  end;\n\n  while i &lt; total do\n  begin\n    i := i + 1;\n    Report(false, i, expected[i], '');\n  end;\n\n  writeln;\n  writeln(passed, ' of ', total, ' checks passed');\n  if failed &gt; 0 then\n    ExitCode := 1;\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Compile the checker and version 1 of \u003Ccode>average.pas\u003C\u002Fcode> with \u003Ccode>fpc\u003C\u002Fcode>, then pipe one into the other.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20.%2Faverage%20%3C%20scores.txt%20%7C%20.%2Fcheck_average%0AFAIL%20%20line%201%3A%20expected%20%22count%3A%206%22%2C%20got%20%22count%3A%205%22%0AFAIL%20%20line%202%3A%20expected%20%22mean%3A%2076.2%22%2C%20got%20%22mean%3A%2078.0%22%0A%0A0%20of%202%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ .\u002Faverage &lt; scores.txt | .\u002Fcheck_average\u003C\u002Fspan>\nFAIL  line 1: expected \"count: 6\", got \"count: 5\"\nFAIL  line 2: expected \"mean: 76.2\", got \"mean: 78.0\"\n\n0 of 2 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The checker exits with status 1 here, so a script can gate on it.\u003C\u002Fp>\n\u003Ch2 id=\"switch-to-a-dynamic-array\">Switch to a dynamic array\u003C\u002Fh2>\n\u003Cp>Replace \u003Ccode>average.pas\u003C\u002Fcode> with version 2. The fixed array becomes \u003Ccode>array of integer\u003C\u002Fcode>, and \u003Ccode>SetLength(scores, n + 1)\u003C\u002Fcode> runs before each read.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20average%3B%0A%0A%7B%20Version%202%3A%20the%20array%20grows%20to%20fit%20whatever%20arrives.%20%7D%0A%0Avar%0A%20%20scores%3A%20array%20of%20integer%3B%0A%20%20n%2C%20sum%3A%20integer%3B%0A%0Abegin%0A%20%20n%20%3A%3D%200%3B%0A%20%20sum%20%3A%3D%200%3B%0A%20%20while%20not%20eof%20do%0A%20%20begin%0A%20%20%20%20SetLength(scores%2C%20n%20%2B%201)%3B%0A%20%20%20%20readln(scores%5Bn%5D)%3B%0A%20%20%20%20sum%20%3A%3D%20sum%20%2B%20scores%5Bn%5D%3B%0A%20%20%20%20n%20%3A%3D%20n%20%2B%201%3B%0A%20%20end%3B%0A%20%20writeln('count%3A%20'%2C%20Length(scores))%3B%0A%20%20writeln('mean%3A%20'%2C%20sum%20%2F%20n%3A0%3A1)%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program average;\n\n{ Version 2: the array grows to fit whatever arrives. }\n\nvar\n  scores: array of integer;\n  n, sum: integer;\n\nbegin\n  n := 0;\n  sum := 0;\n  while not eof do\n  begin\n    SetLength(scores, n + 1);\n    readln(scores[n]);\n    sum := sum + scores[n];\n    n := n + 1;\n  end;\n  writeln('count: ', Length(scores));\n  writeln('mean: ', sum \u002F n:0:1);\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Compile it and run the same pipe.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20.%2Faverage%20%3C%20scores.txt%20%7C%20.%2Fcheck_average%0APASS%20%20line%201%3A%20count%3A%206%0APASS%20%20line%202%3A%20mean%3A%2076.2%0A%0A2%20of%202%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ .\u002Faverage &lt; scores.txt | .\u002Fcheck_average\u003C\u002Fspan>\nPASS  line 1: count: 6\nPASS  line 2: mean: 76.2\n\n2 of 2 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The checker now exits with status 0. Version 2 reports \u003Ccode>Length(scores)\u003C\u002Fcode> as its count, so the number comes from the array itself. The loop has no \u003Ccode>MAX\u003C\u002Fcode> to stop it, and the array ends up as long as the file.\u003C\u002Fp>\n\u003Ch2 id=\"choosing-between-them\">Choosing between them\u003C\u002Fh2>\n\u003Cp>Ask who decides the count. If you decide it when you write the program, use \u003Ccode>array[1..N]\u003C\u002Fcode> with a constant. If the data decides it, use \u003Ccode>array of\u003C\u002Fcode> and index from 0. Build with \u003Ccode>-Cr\u003C\u002Fcode> while you test, because a dynamic array does not stop a write past its end by default.\u003C\u002Fp>\n","\u003Cul>\n\u003Cli>A fixed \u003Ccode>array[1..MAX]\u003C\u002Fcode> stops reading at \u003Ccode>MAX\u003C\u002Fcode> without a warning, which is how six scores produced the mean of five.\u003C\u002Fli>\n\u003Cli>A dynamic array starts with \u003Ccode>Length\u003C\u002Fcode> 0 and equal to \u003Ccode>nil\u003C\u002Fcode>; \u003Ccode>SetLength\u003C\u002Fcode> gives it a length, and the new elements arrive as zero, not as garbage.\u003C\u002Fli>\n\u003Cli>Its indexes run from 0 to \u003Ccode>High\u003C\u002Fcode>, where a static \u003Ccode>array[1..5]\u003C\u002Fcode> runs from 1 to 5.\u003C\u002Fli>\n\u003Cli>\u003Ccode>b := a\u003C\u002Fcode> copies the pointer, so writing through \u003Ccode>b\u003C\u002Fcode> changes \u003Ccode>a\u003C\u002Fcode>; \u003Ccode>Copy(a, start, count)\u003C\u002Fcode> is what makes independent storage.\u003C\u002Fli>\n\u003Cli>\u003Ccode>SetLength(a, 0)\u003C\u002Fcode> releases what \u003Ccode>a\u003C\u002Fcode> points at, but a second variable holding the same block keeps the data alive until the last reference goes.\u003C\u002Fli>\n\u003Cli>Nothing stops a write past the end by default: build with \u003Ccode>-Cr\u003C\u002Fcode> to turn it into \u003Ccode>Runtime error 201\u003C\u002Fcode> instead of silent corruption.\u003C\u002Fli>\n\u003C\u002Ful>\n",[200,219,240,258,273,290],{"id":201,"title":202,"title_id":203,"slug":204,"excerpt":205,"excerpt_id":206,"has_translation":12,"published_at":207,"reading_time":139,"hidden_from_listing":15,"tags":208,"thumbnail_image":21,"og_image":210,"series":211,"authors":216},48,"What a Linked List Actually Is","Tentang Struktur Data LinkedList","tentang-struktur-data-linked-list","A linked list is a linear chain of nodes, each holding data and a pointer to the next node. Here is what that chain looks like, what it costs next to an array, and the same minimal implementation in Java, Python, and JavaScript.","Linked list adalah rantai linear berisi node, dan setiap node menyimpan data plus pointer ke node berikutnya. Ini bentuk rantainya, ongkosnya dibanding array, dan implementasi paling sederhana dalam Java, Python, serta JavaScript.","2026-11-21T01:00:00.000Z",[105,209,156,106],"linked-list","\u002Fog\u002Ftentang-struktur-data-linked-list.png",{"id":212,"title":213,"title_id":214,"slug":215},28,"Linear Data Structures","Struktur Data Linear","asd-struktur-linear",[217],{"authors_id":218},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":220,"title":221,"title_id":222,"slug":223,"excerpt":224,"excerpt_id":225,"has_translation":12,"published_at":226,"reading_time":227,"hidden_from_listing":15,"tags":228,"thumbnail_image":21,"og_image":231,"series":232,"authors":237},47,"Why Understanding Algorithms and Data Structures Actually Matters","Pentingnya Memahami Algoritma dan Struktur Data","pentingnya-memahami-algoritma-dan-struktur-data","An algorithm is an ordered list of steps, and that order decides how expensive a problem is. The examples are on the back of an instant noodle packet, in a factorial, and behind ctrl+z.","Sebagai konsep fundamental, algoritma menentukan seberapa mahal sebuah masalah diselesaikan. Contohnya ada di bungkus mie instan, di bilangan faktorial, dan di tombol undo.","2026-11-19T01:00:00.000Z",7,[229,105,106,230],"algoritma","dasar","\u002Fog\u002Fpentingnya-memahami-algoritma-dan-struktur-data.png",{"id":233,"title":234,"title_id":235,"slug":236},27,"About Algorithms and Data Structures","Tentang Algoritma dan Struktur Data","asd-intro",[238],{"authors_id":239},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":241,"title":242,"title_id":243,"slug":244,"excerpt":245,"excerpt_id":246,"has_translation":12,"published_at":247,"reading_time":248,"hidden_from_listing":15,"tags":249,"thumbnail_image":21,"og_image":252,"series":253,"authors":255},150,"Java Loops: the Last Price That Never Reached the Sum","Loop Java: Harga Terakhir yang Tidak Pernah Masuk ke Total","java-loops","Four prices add up to 47000, and the cart program prints 36500. The bound is `prices.length - 1`, so the last item is never read while the average is still divided by four.","Empat harga berjumlah 47000, tapi program keranjang mencetak 36500. Batasnya `prices.length - 1`, jadi item terakhir tidak pernah dibaca sementara rata-ratanya tetap dibagi empat.","2026-11-13T01:00:00.000Z",6,[250,251],"java","loop","\u002Fog\u002Fjava-loops.png",{"id":254,"title":60,"title_id":61,"slug":62},13,[256],{"authors_id":257},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":259,"title":260,"title_id":261,"slug":262,"excerpt":263,"excerpt_id":264,"has_translation":12,"published_at":265,"reading_time":248,"hidden_from_listing":15,"tags":266,"thumbnail_image":21,"og_image":268,"series":269,"authors":270},149,"Java switch: the 78 That Came Out as a C","Java switch: 78 yang Keluar sebagai C","java-switch","A grading program marks a paper 78 and prints `grade: C`. `case 7` assigns `B` and then runs into `case 6` because the `break` is missing, and the compiler says nothing about it.","Sebuah program penilaian memberi nilai 78 pada satu lembar ujian lalu mencetak `grade: C`. `case 7` memberi `B` lalu jatuh ke `case 6` karena `break`-nya hilang, dan kompilator tidak mengatakan apa pun soal itu.","2026-11-12T01:00:00.000Z",[250,267],"percabangan","\u002Fog\u002Fjava-switch.png",{"id":254,"title":60,"title_id":61,"slug":62},[271],{"authors_id":272},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":274,"title":275,"title_id":276,"slug":277,"excerpt":278,"excerpt_id":279,"has_translation":12,"published_at":265,"reading_time":14,"hidden_from_listing":15,"tags":280,"thumbnail_image":21,"og_image":285,"series":286,"authors":287},108,"At 11 a.m. the AI Quota Runs Out, and the Work Stops There","Jam 11 siang kuota AI-nya habis, dan kerjaan berhenti di situ","jam-11-kuota-ai-habis-kerjaan-berhenti","The panel says the usage limit is reached and the work stops, not because it is finished. Three guesses explain it, and all three are wrong: the limit is shaped like a cliff, and the day is built on top of one tool.","Panel di layar bilang batas pemakaian tercapai, dan kerja berhenti di situ. Bukan karena selesai. Ada tiga tebakan kenapa ini terjadi, dan ketiganya salah: batasnya berbentuk tebing, dan harinya dibangun di atas satu alat.",[281,282,283,284],"ai","tooling","rate-limit","produktivitas","\u002Fog\u002Fjam-11-kuota-ai-habis-kerjaan-berhenti.png",{"id":24,"title":25,"title_id":26,"slug":27},[288],{"authors_id":289},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},{"id":291,"title":292,"title_id":21,"slug":293,"excerpt":294,"excerpt_id":21,"has_translation":15,"published_at":80,"reading_time":248,"hidden_from_listing":15,"tags":295,"thumbnail_image":21,"og_image":298,"series":299,"authors":301},148,"Go Variables: the Mean That Printed 0.0","go-program-structure-and-variables","Six scores arrive, all six are added up, and Go prints a mean of 0.0. A second `total := 0` inside the `if` block is the whole bug, and the compiler that refuses unused variables has nothing to say about it.",[296,230,297],"go","variabel","\u002Fog\u002Fgo-program-structure-and-variables.png",{"id":300,"title":56,"title_id":57,"slug":58},11,[302],{"authors_id":303},{"id":112,"name":113,"slug":114,"role":115,"profile_picture":21},[305,308,311,314,317,320],{"text":306,"depth":154,"id":307},"Give the array a length at run time","give-the-array-a-length-at-run-time",{"text":309,"depth":154,"id":310},"Two names, one array","two-names-one-array",{"text":312,"depth":154,"id":313},"The exception: nothing guards the end","the-exception-nothing-guards-the-end",{"text":315,"depth":154,"id":316},"Make the check fail first","make-the-check-fail-first",{"text":318,"depth":154,"id":319},"Switch to a dynamic array","switch-to-a-dynamic-array",{"text":321,"depth":154,"id":322},"Choosing between them","choosing-between-them",1794557078025]