Debian Codegraph @

docs/content/en/functions/collections/Seq.md

raw
1 ---
2 title: collections.Seq
3 description: Returns a slice of integers starting from 1 or a given value, incrementing by 1 or a given value, and ending at a given value.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: [seq]
9 returnType: '[]int'
10 signatures:
11 - collections.Seq LAST
12 - collections.Seq FIRST LAST
13 - collections.Seq FIRST INCREMENT LAST
14 aliases: [/functions/seq]
15 ---
16
17 ```go-html-template
18 {{ seq 2 }} → [1 2]
19 {{ seq 0 2 }} → [0 1 2]
20 {{ seq -2 2 }} → [-2 -1 0 1 2]
21 {{ seq -2 2 2 }} → [-2 0 2]
22 ```
23
24 A contrived example of iterating over a sequence of integers:
25
26 ```go-html-template
27 {{ $product := 1 }}
28 {{ range seq 4 }}
29 {{ $product = mul $product . }}
30 {{ end }}
31 {{ $product }} → 24
32 ```
33
34 > [!NOTE]
35 > The slice created by this function is limited to 1 million elements.