Repeat

Repeat( value, [ number ] )
Repeat( value, [ number ] )
Repeat( value, [ number ] )
Repeat( value, [ number ] )
repeat( value, [ number ] )
Repeat( value, [ number ] )

Description

The Repeat function returns a string consisting of the value string repeated number times.

Parameters

Argument Type Definition and Requirements

value

The string to repeat.

number

Optional - The number of times that the value string should be repeated. The default is 2.

Returns

A string with the value string repeated the number of times.

Examples

The following query executes an array of independent repeat operations and returns the results in an array. The result array position matches the execution array position. The individual operations are:

  1. The string Yes is concatenated with itself. The result string YesYes is placed in the top position of the result array.

  2. The string Yes! , containing a trailing space, is repeated 3 times. The result string Yes! Yes! Yes! is placed in the second position of the result array.

  3. The string = is repeated 10 times. The result string ========== is placed in the third position of the result array.

Value result = await client.Query(
    Arr(
        Repeat("Yes"),
        Repeat("Yes! ", 3),
        Repeat("=", 10)
    )
);

Console.WriteLine(result);
Arr(StringV(YesYes), StringV(Yes! Yes! Yes! ), StringV(==========))
result, err := client.Query(
	f.Arr{
		f.Repeat("Yes"),
		f.Repeat("Yes! ", f.Number(3)),
		f.Repeat("=", f.Number(10)),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[YesYes Yes! Yes! Yes!  ==========]
System.out.println(
    client.query(
        Arr(
            Repeat("Yes"),
            Repeat("Yes! ", 3),
            Repeat("=", 10)
        )
    ).get());
["YesYes", "Yes! Yes! Yes! ", "=========="]
client.query(
  [
    q.Repeat('Yes'),
    q.Repeat('Yes! ', 3),
    q.Repeat('=', 10),
  ]
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
[ 'YesYes', 'Yes! Yes! Yes! ', '==========' ]
result = client.query(
  [
    q.repeat("Yes"),
    q.repeat("Yes! ", 3),
    q.repeat("=", 10),
  ]
)
print(result)
['YesYes', 'Yes! Yes! Yes! ', '==========']
println(Await.result(
    client.query(
        Arr(
            Repeat("Yes"),
            Repeat("Yes! ", 3),
            Repeat("=", 10)
        )
    ),
    5.seconds
))
["YesYes", "Yes! Yes! Yes! ", "=========="]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!