diff options
| author | Cliff Click <cliffc@acm.org> | 2026-12-04 13:51:35 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-12-04 13:51:35 -0800 |
| commit | 7be87ff4db692a392af1c68abe7752a1da55637f (patch) | |
| tree | d5e8e68bed74166aeaf4b658f9ce104d1df48c8a /chapter32/docs/examples/Capitalize.smp | |
| parent | f0a6c6757a795b8e186de0076836a87acef59fa7 (diff) | |
| parent | ebdb2c71237506d67cfa8f3bb459b41902840481 (diff) | |
| download | Simple-7be87ff4db692a392af1c68abe7752a1da55637f.tar.gz Simple-7be87ff4db692a392af1c68abe7752a1da55637f.zip | |
Merge pull request #265 from SeaOfNodes/ch32main
Land Chapter 32 compiler performance work and backported fixes
Diffstat (limited to 'chapter32/docs/examples/Capitalize.smp')
| -rw-r--r-- | chapter32/docs/examples/Capitalize.smp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/chapter32/docs/examples/Capitalize.smp b/chapter32/docs/examples/Capitalize.smp new file mode 100644 index 00000000..00fdd481 --- /dev/null +++ b/chapter32/docs/examples/Capitalize.smp @@ -0,0 +1,23 @@ + +// 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]; + u32 len = input#; + sys.ary.copy(output,0,input,0,len); + output[0] = sys.char.toupper(input[0]); + output[input#] = '\n'; + sys.io.p(output); + return 0; +}; |
