This might seem overkill. ;-) Look at the (forthcoming) proceedings of the GuITMeeting 2016 (to be held at the end of October) for comments over the code.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\providecommand\fpeval{\fp_eval:n}
\NewDocumentCommand{\nforeach}{ m +m }
{
\tl_clear:N \l__manual_nforeach_type_tl
\keys_set:nn { manual/nforeach }
{
type=integers,start = 1, step = 1, end = 0,
}
\keys_set:nn { manual/nforeach } { #1 }
\__manual_nforeach_exec:n { #2 }
}
\int_new:N \g__manual_foreach_map_int
\int_new:N \g__manual_fp_map_int
\tl_new:N \l__manual_nforeach_type_tl
\keys_define:nn { manual/nforeach }
{
type .choice:,
type .value_required:n = true,
type/integers .code:n = \tl_set:Nn \l__manual_nforeach_type_tl { integers },
type/fp .code:n = \tl_set:Nn \l__manual_nforeach_type_tl { fp },
type/alph .code:n = \tl_set:Nn \l__manual_nforeach_type_tl { alph },
type/Alph .code:n = \tl_set:Nn \l__manual_nforeach_type_tl { Alph },
start .tl_set:N = \l__manual_nforeach_start_tl,
step .tl_set:N = \l__manual_nforeach_step_tl,
end .tl_set:N = \l__manual_nforeach_end_tl,
}
\cs_new_protected:Nn \__manual_nforeach_exec:n
{
\int_gincr:N \g__manual_foreach_map_int
\str_case:Vn \l__manual_nforeach_type_tl
{
{integers}{\__manual_nforeach_exec_integers:n { #1 }}
{fp} {\__manual_nforeach_exec_fp:n { #1 }}
{alph} {\__manual_nforeach_exec_alph:Nn \int_to_alph:n { #1 }}
{Alph} {\__manual_nforeach_exec_alph:Nn \int_to_Alph:n { #1 }}
}
\int_gdecr:N \g__manual_foreach_map_int
}
\cs_generate_variant:Nn \str_case:nn { V }
\cs_new_protected:Nn \__manual_nforeach_exec_integers:n
{
\int_step_inline:nnnn
{ \l__manual_nforeach_start_tl }
{ \l__manual_nforeach_step_tl }
{ \l__manual_nforeach_end_tl }
{ #1 }
}
\cs_new_protected:Nn \__manual_nforeach_exec_alph:Nn
{
\cs_set:cn { __manual_nforeach_alph_ \int_use:N \g__manual_foreach_map_int :n } { #2 }
\cs_generate_variant:cn
{ __manual_nforeach_alph_ \int_use:N \g__manual_foreach_map_int :n }
{ f }
\int_step_inline:nnnn
{ \int_from_alph:f { \l__manual_nforeach_start_tl } }
{ \l__manual_nforeach_step_tl }
{ \int_from_alph:f { \l__manual_nforeach_end_tl } }
{
\use:c { __manual_nforeach_alph_ \int_use:N \g__manual_foreach_map_int :f }
{ #1 { ##1 } }
}
}
\cs_generate_variant:Nn \cs_generate_variant:Nn { c }
\cs_generate_variant:Nn \int_from_alph:n { f }
\cs_new_protected:Nn \__manual_nforeach_exec_fp:n
{
\manual_fp_step_inline:nnnn
{ \l__manual_nforeach_start_tl }
{ \l__manual_nforeach_step_tl }
{ \l__manual_nforeach_end_tl }
{ #1 }
}
% a replacement for \fp_step_inline:nnnn
\seq_new:N \l__manual_fp_step_seq
\fp_new:N \l__manual_fp_step_start_fp
\cs_new_protected:Nn \manual_fp_step_inline:nnnn
{
\int_gincr:N \g__manual_fp_map_int
\seq_clear_new:c { l__manual_fp_step_ \int_use:N \g__manual_fp_map_int _seq }
\fp_compare:nTF { #2 < \c_zero_fp }
{
\__manual_fp_step_make_neg:nnn { #1 } { #2 } { #3 }
}
{
\__manual_fp_step_make_pos:nnn { #1 } { #2 } { #3 }
}
\seq_map_inline:cn { l__manual_fp_step_ \int_use:N \g__manual_fp_map_int _seq } { #4 }
\int_gdecr:N \g__manual_fp_map_int
}
\cs_new_protected:Nn \__manual_fp_step_make_neg:nnn
{
\fp_set:Nn \l__manual_fp_step_start_fp { #1 }
\fp_do_while:nn { \l__manual_fp_step_start_fp >= #3 }
{
\seq_put_right:cx { l__manual_fp_step_ \int_use:N \g__manual_fp_map_int _seq }
{ \fp_eval:n { \l__manual_fp_step_start_fp } }
\fp_add:Nn \l__manual_fp_step_start_fp { #2 }
}
}
\cs_new_protected:Nn \__manual_fp_step_make_pos:nnn
{
\fp_set:Nn \l__manual_fp_step_start_fp { #1 }
\fp_do_while:nn { \l__manual_fp_step_start_fp <= #3 }
{
\seq_put_right:cx { l__manual_fp_step_ \int_use:N \g__manual_fp_map_int _seq }
{ \fp_eval:n { \l__manual_fp_step_start_fp } }
\fp_add:Nn \l__manual_fp_step_start_fp { #2 }
}
}
\NewDocumentCommand{\lforeach}{ s O{} m +m }
{
\IfBooleanTF{#1}
{
\manual_lforeach:non { #2 } { #3 } { #4 }
}
{
\manual_lforeach:nnn { #2 } { #3 } { #4 }
}
}
\cs_new_protected:Nn \manual_lforeach:nnn
{
\keys_set:nn { manual/lforeach } { single }
\keys_set:nn { manual/lforeach } { #1 }
\clist_set:Nn \l__manual_lforeach_list_clist { #2 }
\int_gincr:N \g__manual_foreach_map_int
\__manual_lforeach_define:n { #3 }
\clist_map_inline:Nn \l__manual_lforeach_list_clist
{
\use:c { __manual_lforeach_ \int_use:N \g__manual_foreach_map_int _action:w } ##1 \q_stop
}
\int_gdecr:N \g__manual_foreach_map_int
}
\cs_generate_variant:Nn \manual_lforeach:nnn { no }
\cs_new_protected:Nn \__manual_lforeach_define:n
{
\exp_last_unbraced:NcV
\cs_set:Npn
{ __manual_lforeach_ \int_use:N \g__manual_foreach_map_int _action:w }
\l__manual_lforeach_format_tl
\q_stop
{#1}
}
\keys_define:nn { manual/lforeach }
{
format .tl_set:N = \l__manual_lforeach_format_tl,
single .code:n = \tl_set:Nn \l__manual_lforeach_format_tl { ##1 },
double .code:n = \tl_set:Nn \l__manual_lforeach_format_tl { ##1/##2 },
triple .code:n = \tl_set:Nn \l__manual_lforeach_format_tl { ##1/##2/##3 },
}
%%% for this application
\NewDocumentCommand{\newlist}{m}
{
\seq_clear_new:c { l_manual_list_#1_seq }
}
\NewDocumentCommand{\addtolist}{mm}
{
\seq_put_right:cn { l_manual_list_#1_seq } { #2 }
}
\NewDocumentCommand{\uselist}{mm}
{
\seq_use:cn { l_manual_list_#1_seq } { #2 }
}
\NewDocumentCommand{\showlist}{m}
{
\seq_show:c { l_manual_list_#1_seq }
}
\ExplSyntaxOff
\newlist{listA}\newlist{listB}
\begin{document}
\[
% first table
\lforeach[format=#1/#2/#3/#4,]{
8/93/64/61,
7/186/32/61,
6/231/32/29,
5/462/16/29,
4/483/16/13,
3/966/8/13,
2/975/8/5,
1/1950/4/5,
0/1953/4/1,
}{\addtolist{listA}{x_{#1}=#2 & y_{#1}=#3 & z_{#1}=#4 \\}}
% second table
\nforeach{start=5,step=-1,end=0}{%
\addtolist{listB}{
x_{#1}=\fpeval{65*2^(5-#1)} &
y_{#1}=\fpeval{2^(#1+2)} &
z_{#1}=1 \\
}%
}
\begin{array}[t]{lll}
\uselist{listA}{}
\end{array}
\qquad
\begin{array}[t]{lll}
\uselist{listB}{}
\end{array}
\]
\end{document}

Of course, the left-hand table can also be typeset by
\documentclass{article}
\begin{document}
\[
\def\row#1/#2/#3/#4,{%
x_{#1}=#2 & y_{#1}=#3 & z_{#1}=#4 \\
}
\begin{array}{lll}
\row 8/93/64/61,
\row 7/186/32/61,
\row 6/231/32/29,
\row 5/462/16/29,
\row 4/483/16/13,
\row 3/966/8/13,
\row 2/975/8/5,
\row 1/1950/4/5,
\row 0/1953/4/1,
\end{array}
\]
\end{document}
but it's no fun. ;-)
align(*)supports multiple alignment points. Here is the syntax for the first line:x_8 &=93 & y_8 &= 64 & z_8=61 \\, then just repeat (of course assumes theamsmathpackage) – daleif Sep 02 '16 at 15:04alignatthough it has a slightly different syntax – daleif Sep 02 '16 at 17:25