summaryrefslogtreecommitdiff
path: root/chapter24/docs/examples
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-24 15:41:48 -0700
committerCliff Click <cliffc@acm.org>2026-10-24 15:41:48 -0700
commit489672dfac7efc78fc239ba7c2dfc82f1c5fbeab (patch)
tree9f4e04ed9d4f7443c03b02269cc77a96bb23dbd0 /chapter24/docs/examples
parentfeb98e1bb6c973428b94591ed5b0aed5e4137bd0 (diff)
downloadSimple-489672dfac7efc78fc239ba7c2dfc82f1c5fbeab.tar.gz
Simple-489672dfac7efc78fc239ba7c2dfc82f1c5fbeab.zip
Finish chapter numbering, retire combined chapter 24, and update documentation
Diffstat (limited to 'chapter24/docs/examples')
-rw-r--r--chapter24/docs/examples/A_helloWorld.smp3
-rw-r--r--chapter24/docs/examples/BubbleSort.smp37
2 files changed, 0 insertions, 40 deletions
diff --git a/chapter24/docs/examples/A_helloWorld.smp b/chapter24/docs/examples/A_helloWorld.smp
deleted file mode 100644
index 07ff935f..00000000
--- a/chapter24/docs/examples/A_helloWorld.smp
+++ /dev/null
@@ -1,3 +0,0 @@
-// -*- mode: java; -*-
-sys.io.p("Hello, World!");
-return 0;
diff --git a/chapter24/docs/examples/BubbleSort.smp b/chapter24/docs/examples/BubbleSort.smp
deleted file mode 100644
index 938e3181..00000000
--- a/chapter24/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;
-};