Created
October 8, 2012 09:55
-
-
Save kmaed/3851753 to your computer and use it in GitHub Desktop.
2012/10/08 の失敗例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%#! 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 | |
len_count = len_count+2 % \newcount\@tempcnta の分を足す | |
print(); print() | |
print('len(yourcode)=' .. tostring(len_count)) | |
end | |
len_count = len_count + 1 | |
end | |
}} | |
\def\length#1{\len@begin#1\len@end#1} | |
\newcount\@tempcnta | |
\length{% ここから数える | |
\def\numtohex#1{% | |
\@tempcnta#1\divide\@tempcnta\sixt@@n% | |
\count@\numexpr#1-\sixt@@n*\@tempcnta | |
\edef\result{\@numtohex\@tempcnta\@numtohex\count@}}% | |
\def\@numtohex#1{\ifcase\numexpr#1-10 A\or B\or C\or D\or E\or F\else\number#1\fi}% ここまで | |
} | |
\catcode`\@=12 | |
\numtohex{042}\show\result %==>2A | |
\numtohex{`\\}\show\result %==>5C | |
\count0=3 \numtohex{\count0}\show\result %==>03 | |
\bye |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://d.hatena.ne.jp/zrbabbler/20121008/1349677570