Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ExplSyntaxOn
- NewExpandableDocumentCommand{ForA}{ O {1} m m }{
- fp_step_inline:nnnn { #2 } { #1 } { fp_eval:n { #2+#1*(#3-2) } } { ##1, } fp_eval:n { #2+#1*(#3-1) } }
- ExplSyntaxOff
- ForA[1]{1}{9}
- functiontableT{ 1/4,1/3,1/2,ForA[1]{1}{9},15}{ 1/#1^2 }
- documentclass{article}
- usepackage{xfp}
- usepackage{xintexpr}
- usepackage{siunitx}
- sisetup{group-separator={,},output-decimal-marker={,}}
- ExplSyntaxOn
- seq_new:N l__ts_funcT_row_one_seq
- seq_new:N l__ts_funcT_row_two_seq
- NewDocumentCommand{functiontableT}{ m m }
- {% #1 = list of values, #2 = function
- group_begin:
- cs_set:Nn __ts_funcT_function:n { #2 }
- seq_clear:N l__ts_funcT_row_one_seq
- seq_clear:N l__ts_funcT_row_two_seq
- clist_map_inline:nn { #1 }
- { seq_put_right:Nn l__ts_funcT_row_one_seq
- { $ xintFrac{xinttheexpr reduce( ##1 ) relax } $ }
- seq_put_right:Nx l__ts_funcT_row_two_seq
- { num{ fp_eval:n{round( __ts_funcT_function:n { fp_eval:n { ##1 } }, 2 ) } } }
- }
- use:x { exp_not:N begin{tabular}{ c *{seq_count:N l__ts_funcT_row_one_seq}{|c}} }
- $ x $ & seq_use:Nn l__ts_funcT_row_one_seq { & }
- tabularnewline hline
- $ f(x) $ & seq_use:Nn l__ts_funcT_row_two_seq { & }
- end{tabular}
- group_end:
- } %
- ExplSyntaxOff
- ExplSyntaxOn
- NewExpandableDocumentCommand{ForA}{ O {1} m m }{
- fp_step_inline:nnnn { #2 } { #1 } { fp_eval:n { #2+#1*(#3-2) } } { ##1, } fp_eval:n { #2+#1*(#3-1) } }
- ExplSyntaxOff
- begin{document}
- ForA[1]{1}{9}
- functiontableT{ 1/4,1/3,1/2,1,2,3,4,5,6,7,8,9}{ 1/#1^2 }
- end{document}
Add Comment
Please, Sign In to add comment