diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-24 15:25:40 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-24 15:25:40 -0700 |
| commit | c4364363dbd969c9aa27aa7c43fbe6d40544501a (patch) | |
| tree | 8b0493b3a787f98da87531058e24cf4eaab970a6 /chapter-escape/docs/examples | |
| parent | 6ff5bb750b8d571a48204539b90c52c1e17283d5 (diff) | |
| download | Simple-c4364363dbd969c9aa27aa7c43fbe6d40544501a.tar.gz Simple-c4364363dbd969c9aa27aa7c43fbe6d40544501a.zip | |
Rename escape analysis chapter to 27
Diffstat (limited to 'chapter-escape/docs/examples')
| -rw-r--r-- | chapter-escape/docs/examples/A_helloWorld.smp | 3 | ||||
| -rw-r--r-- | chapter-escape/docs/examples/BubbleSort.smp | 37 |
2 files changed, 0 insertions, 40 deletions
diff --git a/chapter-escape/docs/examples/A_helloWorld.smp b/chapter-escape/docs/examples/A_helloWorld.smp deleted file mode 100644 index 07ff935f..00000000 --- a/chapter-escape/docs/examples/A_helloWorld.smp +++ /dev/null @@ -1,3 +0,0 @@ -// -*- mode: java; -*- -sys.io.p("Hello, World!"); -return 0; diff --git a/chapter-escape/docs/examples/BubbleSort.smp b/chapter-escape/docs/examples/BubbleSort.smp deleted file mode 100644 index 938e3181..00000000 --- a/chapter-escape/docs/examples/BubbleSort.smp +++ /dev/null @@ -1,37 +0,0 @@ -// -*- mode: java; -*- - -// An implementation of -// https://sampleprograms.io/projects/bubble-sort/ -// -// Bubble sort, with reading (parsing) and writing (formatting) the data. - -val sort = { !sys.aryi64 nums -> - var done = false; - while( !done ) { - done = true; - for( var i = 0; i < nums.len-1; i++ ) - if( nums.buf[i] > nums.buf[i+1] ) { - int tmp = nums.buf[i]; - nums.buf[i] = nums.buf[i+1]; - nums.buf[i+1] = tmp; // Swap - done = false; - } - } -}; - -// Read from stdin a line of the form "[ 4, 3, 2, 1]" and print it sorted. -val main = { -> - // Parse array of numbers from stdin - var nums = sys.parseAryI64( sys.io.stdin() ); - if( !nums ) { - sys.io.p("stdin must look like [4, 3, 2, 1]"); - return 1; - } - - // Bubble sort array of integers - sort(nums); - - // Print a list of numbers to stdout - nums.str().write(1); - return 0; -}; |
