Wishes: hex-output

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Wishes: hex-output

Erik Reitsma (RY/ETM)-2
Or alternatively replace 32 with ($a-$A):
 ucase([C|Cs]) when C>=$a,C=<$z -> [C-($a-$A)|ucase(Cs)]; % a-z
 ucase([C|Cs])                  -> [C|ucase(Cs)];
 ucase([])                      -> [].
 lcase([C|Cs]) when C>=$A,C=<$Z -> [C-($A-$a)|lcase(Cs)]; % A-Z
 lcase([C|Cs])                  -> [C|lcase(Cs)];
 lcase([])                      -> [].
 capw([C|Cs]) when C>=$a,C=<$z  -> [C-($a-$A)|lcase(Cs)];
 capw(Cs)                       -> lcase(Cs).

This only relies on $a-$z and $A-$Z being consecutive integer intervals, not on the distance between these intervals (which is 32 in case of ASCII). I just hope that the compiler will optimize $a-$A, otherwise this would require more computation...