String case: Difference between revisions

(→‎{{header|OCaml}}: new functions name since ocaml 4.03.0)
Line 2,311:
output = swapc(str)
end</lang>
 
An alternative way of constructing the above that groups related functions together in a denser display:
 
<lang SNOBOL4> define('UC(STR)')
define('LC(STR)')
define('UCFIRST(STR)')
define('SWAPC(STR)') :(CASES.END)
UC uc = replace(str,&lcase,&ucase) :(RETURN)
LC lc = replace(str,&ucase,&lcase) :(RETURN)
UCFIRST str len(1) . ch = uc(ch) ; ucfirst = str :(RETURN)
SWAPC swapc = replace(str, &ucase &lcase, &lcase &ucase) :(RETURN)
CASES.END
 
* # Test and display
str = 'alphaBETA'
output = str
output = lc(str)
output = uc(str)
output = ucfirst(str)
output = swapc(str)
END</lang>
 
Output: