all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
34
Task/String-case/Metafont/string-case-1.metafont
Normal file
34
Task/String-case/Metafont/string-case-1.metafont
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
vardef isbetween(expr a, i, f) =
|
||||
if string a:
|
||||
if (ASCII(a) >= ASCII(i)) and (ASCII(a) <= ASCII(f)):
|
||||
true
|
||||
else:
|
||||
false
|
||||
fi
|
||||
else:
|
||||
false
|
||||
fi enddef;
|
||||
|
||||
vardef toupper(expr s) =
|
||||
save ?; string ?; ? := ""; d := ASCII"A" - ASCII"a";
|
||||
for i = 0 upto length(s)-1:
|
||||
if isbetween(substring(i, i+1) of s, "a", "z"):
|
||||
? := ? & char(ASCII(substring(i,i+1) of s) + d)
|
||||
else:
|
||||
? := ? & substring(i, i+1) of s
|
||||
fi;
|
||||
endfor
|
||||
?
|
||||
enddef;
|
||||
|
||||
vardef tolower(expr s) =
|
||||
save ?; string ?; ? := ""; d := ASCII"a" - ASCII"A";
|
||||
for i = 0 upto length(s)-1:
|
||||
if isbetween(substring(i, i+1) of s, "A", "Z"):
|
||||
? := ? & char(ASCII(substring(i,i+1) of s) + d)
|
||||
else:
|
||||
? := ? & substring(i, i+1) of s
|
||||
fi;
|
||||
endfor
|
||||
?
|
||||
enddef;
|
||||
4
Task/String-case/Metafont/string-case-2.metafont
Normal file
4
Task/String-case/Metafont/string-case-2.metafont
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
message toupper("alphaBETA");
|
||||
message tolower("alphaBETA");
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue