Instantly share code, notes, and snippets.

Embed
What would you like to do?
2012/10/08 の解答
%#! luatex
\catcode`\@=11
\def\len@begin{\directlua{
local len_count = 0
local len_flag = true
while len_flag do
local t = token.get_next()
if token.csname_name(t) == 'len@end' then
len_flag = false
print(); print()
print('len(yourcode)=' .. tostring(len_count))
end
len_count = len_count + 1
end
}}
\def\length#1{\len@begin#1\len@end#1}
\length{% ここから
\def\@numtohex#1"#2\relax{\edef\result{\ifnum"#2<\sixt@@n0\fi#2}}%
\def\numtohex#1{\chardef\@tempchar#1\edef\@temp{\meaning\@tempchar}\expandafter\@numtohex\@temp\relax}% ここまで
}
\catcode`\@=12
\numtohex{042}\show\result %==>2A
\numtohex{`\\}\show\result %==>5C
\count0=3 \numtohex{\count0}\show\result %==>03
\bye
@kmaed

This comment has been minimized.

Copy link
Owner Author

kmaed commented Oct 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment