diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-24 15:31:01 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-24 15:31:01 -0700 |
| commit | feb98e1bb6c973428b94591ed5b0aed5e4137bd0 (patch) | |
| tree | ee104333658a452590546c483fda1cae315ce134 /chapter28b/src/test/smp/examples/Capitalize.smp | |
| parent | e2b042bd9721995486f4f0cf96847c02d27908e3 (diff) | |
| download | Simple-feb98e1bb6c973428b94591ed5b0aed5e4137bd0.tar.gz Simple-feb98e1bb6c973428b94591ed5b0aed5e4137bd0.zip | |
Finish separate compilation snapshot in chapter 28b
Diffstat (limited to 'chapter28b/src/test/smp/examples/Capitalize.smp')
| -rw-r--r-- | chapter28b/src/test/smp/examples/Capitalize.smp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/chapter28b/src/test/smp/examples/Capitalize.smp b/chapter28b/src/test/smp/examples/Capitalize.smp new file mode 100644 index 00000000..8e31c18f --- /dev/null +++ b/chapter28b/src/test/smp/examples/Capitalize.smp @@ -0,0 +1,22 @@ + +// An implementation of +// https://sampleprograms.io/projects/capitalize/ + +val main = { u8[~][] args -> + if( args# > 2 ) { + sys.io.p("Use quotes around multiple strings.\n"); + return 0; + } + if( args# != 2 || args[1]# == 0 ) { + sys.io.p("Usage: please provide a string\n"); + return 0; + } + + u8[~] input = args[1]; + var output = new u8[input# + 1]; + sys.ary.copy(output,0,input,0,input#); + output[0] = sys.char.toupper(input[0]); + output[input#] = '\n'; + sys.io.p(output); + return 0; +}; |
