logo

utils

~/.local/bin tools and git-hooks
commit: c61a55a7500ef70901bc897c9f1c3244fbcbe263
parent: d3adbd69181a943d6b7d096391bf42a38f1a66de
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri,  3 Mar 2017 19:07:29 +0100

range: reverse range

Diffstat:

Mrange.c8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/range.c b/range.c @@ -10,8 +10,12 @@ void usage(char *a0) { void range(int initial, int maximum) { printf("%i", initial); - for(initial++; initial<=maximum; initial++) { - printf("%s%i", IFS, initial); + if(initial<maximum) { + for(initial++; initial<=maximum; initial++) + printf("%s%i", IFS, initial); + } else if(initial>maximum) { + for(initial--; initial>=maximum; initial--) + printf("%s%i", IFS, initial); } }