That's true Eric,
 But we do not know in advance what is the number, and it is given by user!
So if n is a variable, then how we can generate these numbers?

--Mohammad

On Friday, February 15, 2019 at 8:48:15 PM UTC+3:30, Eric Shulman wrote:
>
> On Friday, February 15, 2019 at 8:18:05 AM UTC-8, Mohammad wrote:
>
>> To produce numbers zero padded like
>> 001 002 003 ... 099 100
>> Here is a macro to do that
>> \define zeropad-range(n:10)
>> <$list filter="[range[1,$n$]]" variable=x >
>> <$reveal type="lteq" default=<<x>> text="9" >
>> <$text text= {{{[<x>addprefix[00]]}}} />
>> </$reveal>
>> <$reveal type="gt" default=<<x>> text="9" >
>> <$text text= {{{[<x>addprefix[0]]}}} />
>> </$reveal>
>> </$list>
>> \end
>> The below macro works up to 1000
>> \define zeropad-range4(n:10)
>> <$list filter="[range[1,$n$]]" variable=x >
>> <$reveal type="lteq" default=<<x>> text="9" >
>> <$text text= {{{[<x>addprefix[000]]}}} />
>> </$reveal>
>> <$reveal type="gt" default=<<x>> text="9" >
>> <$reveal type="lt" default=<<x>> text="99" >
>> <$text text= {{{[<x>addprefix[00]]}}} />
>> </$reveal>
>> </$reveal>
>> <$reveal type="gt" default=<<x>> text="99" >
>> <$text text= {{{[<x>addprefix[0]]}}} />
>> </$reveal>
>> </$list>
>> \end
>>
>
> The following filter sequence will generate a list of zero-padded numbers 
> 001-999
> [range[9]addprefix[00]] [range[10,99]addprefix[0]] [range[100,999]]
>
> Thus, to produce the same *display* output as your macro, we can just 
> write:
> {{{ [range[9]addprefix[00]] [range[10,99]addprefix[0]] [range[100,999]] 
> }}}
>
> -e
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3b67634c-7301-43b3-abf1-fae8de5a7267%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to