How to Repeat the word n times?

I have tiddler with 2 fields
name:Max
quantity:5

How can write $filter to get result “Max Max Max Max Max”

Perhaps use a function

\function n.times(input n:1 join:" ") [range[1],<n>then<input>join<join>]

{{{ [n.times{!!name},{!!quantity}] }}}

or even,

{{{ [n.times{!!name},{!!quantity},[, ]] }}}
2 Likes

What does this mean? Thanks.

Just try it, it means to join each repeat with ,_ or comma space, I had to join them and so had to place a space between each item, so I thought make it an optional parameter; also try {{{ [n.times{!!name},{!!quantity},[ - ]] }}} space/hypen/space.

I am curious why you would do this?

But with the above method you can also do this if you dont need to reference fields, and don’t want it to create a link.

<<n.times "Fred" 4 " - ">>

Or if you still want to use the field values;

<$macrocall $name="n.times" input={{!!name}} n={{!!quantity}} join=" -o0o- "/>

<$transclude $variable="n.times" input={{!!name}} n={{!!quantity}} join=" -o0o- "/>

Results;

the name -o0o- the name -o0o- the name

the name -o0o- the name -o0o- the name

Try all of these on tiddlywiki.com

1 Like