Created
September 30, 2012 06:32
-
-
Save kmaed/3806046 to your computer and use it in GitHub Desktop.
2012/09/17 の解答(!!?)
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
%#! lualatex | |
\documentclass[a4paper]{article} | |
\makeatletter | |
\def\len@begin{\directlua{ | |
local len_count = 0 | |
local len_flag = true | |
while len_flag do | |
local t = token.get_next() | |
% print(token.csname_name(t)) | |
if token.csname_name(t) == 'len@end' then | |
len_flag = false | |
for i = 1, len_count do | |
tex.write('*') | |
end | |
end | |
len_count = len_count + 1 | |
end | |
}} | |
\def\len@end{done!} | |
\def\length#1{\len@begin#1\len@end} | |
\makeatother | |
\begin{document} | |
\def\check{\ifx\result\checkstr OK\else NG\fi} | |
\edef\result{\length{ \a {b\cd ef{g} }\h }} | |
\def\checkstr{*************} | |
\check | |
\edef\result{\length{{ }{ {}} {}}} | |
\def\checkstr{***********} | |
\check | |
\escapechar=-1 | |
\edef\result{\length{\expandafter\expandafter\expandafter}} | |
\escapechar=`\\ | |
\def\checkstr{***} | |
\check | |
\edef\result{\expandafter\length\expandafter{\csname ?TeX\endcsname}} | |
\def\checkstr{*} | |
\check | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://d.hatena.ne.jp/zrbabbler/20120917/1347856569