diff options
Diffstat (limited to 'macros/latex/contrib/profcollege/latex/PfCRangementNombres.tex')
-rw-r--r-- | macros/latex/contrib/profcollege/latex/PfCRangementNombres.tex | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/macros/latex/contrib/profcollege/latex/PfCRangementNombres.tex b/macros/latex/contrib/profcollege/latex/PfCRangementNombres.tex new file mode 100644 index 0000000000..f44525f170 --- /dev/null +++ b/macros/latex/contrib/profcollege/latex/PfCRangementNombres.tex @@ -0,0 +1,67 @@ +%%% +% Rangement des nombres +%%% +\setKVdefault[ClesRgt]{Croissant,Decroissant=false,Strict,Fraction=false,Details=false} + +\dtlexpandnewvalue% +\DTLgnewdb{mtnumedb}% +\DTLgnewdb{mtRGTdb}% Pb de doublon avec mtdb de Mediane + +\newcommand\Rangement[2][]{% + \useKVdefault[ClesRgt]% + \setKV[ClesRgt]{#1}% + \ifboolKV[ClesRgt]{Fraction}{% + \setsepchar[*]{,*/}\ignoreemptyitems% + \readlist*\ListeRgt{#2}% + % on cherche le d\'enominateur commun + \ppcm=1\relax + \foreachitem\x\in\ListeRgt{% + \PPCM{\fpeval{\ListeRgt[\xcnt,2]}}{\fpeval{\the\ppcm}}% + }% + % On cr\'ee la liste des rangements. + \DTLcleardb{mtnumedb}% +% % on les trie pour les ranger par ordre croissant + \foreachitem\x\in\ListeRgt{% + \DTLnewrow{mtnumedb}% + \xdef\toto{\fpeval{\ListeRgt[\xcnt,1]*\the\ppcm/\ListeRgt[\xcnt,2]}}% + \DTLnewdbentry{mtnumedb}{numeric}{\toto}% + }% +% % On trie + \ifboolKV[ClesRgt]{Decroissant}{% +% % On trie la liste + \dtlsort{numeric=descending}{mtnumedb}{\dtlicompare}% + \ifboolKV[ClesRgt]{Details}{\ensuremath{\DTLforeach{mtnumedb}{\numeroDonnee=numeric}{\frac{\num{\numeroDonnee}}{\num{\the\ppcm}}\DTLiflastrow{}{\ifboolKV[ClesRgt]{Strict}{>}{\geqslant}}}}}{% + \ensuremath{\DTLforeach{mtnumedb}{\numeroDonnee=numeric}{\Simplification{\numeroDonnee}{\ppcm}\DTLiflastrow{}{\ifboolKV[ClesRgt]{Strict}{>}{\geqslant}}}}% + } + }{% +% % On trie la liste + \dtlsort{numeric}{mtnumedb}{\dtlicompare}% + \ifboolKV[ClesRgt]{Details}{% + \ensuremath{\DTLforeach{mtnumedb}{\numeroDonnee=numeric}{\frac{\num{\numeroDonnee}}{\num{\the\ppcm}}\DTLiflastrow{}{\ifboolKV[ClesRgt]{Strict}{<}{\leqslant}}}}% + }{% + \ensuremath{\DTLforeach{mtnumedb}{\numeroDonnee=numeric}{\Simplification{\numeroDonnee}{\ppcm}\DTLiflastrow{}{\ifboolKV[ClesRgt]{Strict}{<}{\leqslant}}}}% + }% + }% + }{% + \setsepchar{,}\ignoreemptyitems% + \readlist*\ListeRgt{#2}% + % on cr\'ee la base de donn\'ees des valeurs + \DTLcleardb{mtRGTdb}% +% % on les trie pour les ranger par ordre croissant + \foreachitem\x\in\ListeRgt{% + \DTLnewrow{mtRGTdb}% + \itemtomacro\ListeRgt[\xcnt]\y% + \DTLnewdbentry{mtRGTdb}{numeric}{\y}% + }% +% % + \ifboolKV[ClesRgt]{Decroissant}{% + % On trie la liste + \dtlsort{numeric=descending}{mtRGTdb}{\dtlicompare}% + \ensuremath{\DTLforeach{mtRGTdb}{\numeroDonnee=numeric}{\num{\numeroDonnee}\DTLiflastrow{}{\ifboolKV[ClesRgt]{Strict}{>}{\geqslant}}}}% + }{% +% % On trie la liste + \dtlsort{numeric}{mtRGTdb}{\dtlicompare}% + \ensuremath{\DTLforeach{mtRGTdb}{\numeroDonnee=numeric}{\num{\numeroDonnee}\DTLiflastrow{}{\ifboolKV[ClesRgt]{Strict}{<}{\leqslant}}}}% + }% + }% +}%
\ No newline at end of file |