Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/String-case/BCPL/string-case.bcpl
Normal file
26
Task/String-case/BCPL/string-case.bcpl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
get "libhdr"
|
||||
|
||||
// Check whether a character is an upper or lowercase letter
|
||||
let islower(x) = 'a' <= x <= 'z'
|
||||
let isupper(x) = 'A' <= x <= 'Z'
|
||||
|
||||
// Convert a character to upper or lowercase
|
||||
let toupper(x) = islower(x) -> x - 32, x
|
||||
let tolower(x) = isupper(x) -> x + 32, x
|
||||
|
||||
// Map a character function over a string
|
||||
let strmap(f,s) = valof
|
||||
$( for i=1 to s%0 do s%i := f(s%i)
|
||||
resultis s
|
||||
$)
|
||||
|
||||
// Convert a string to upper or lowercase
|
||||
let strtoupper(s) = strmap(toupper,s)
|
||||
let strtolower(s) = strmap(tolower,s)
|
||||
|
||||
let start() be
|
||||
$( let s = "alphaBETA"
|
||||
writef(" String: %S*N", s)
|
||||
writef("Uppercase: %S*N", strtoupper(s))
|
||||
writef("Lowercase: %S*N", strtolower(s))
|
||||
$)
|
||||
Loading…
Add table
Add a link
Reference in a new issue