github.com/rabbouni145/gg@v0.47.1/docs/content/en/functions/seq.md (about) 1 --- 2 title: seq 3 # linktitle: 4 description: Creates a sequence of integers. 5 godocref: 6 date: 2017-02-01 7 publishdate: 2017-02-01 8 lastmod: 2017-02-01 9 categories: [functions] 10 menu: 11 docs: 12 parent: "functions" 13 keywords: [] 14 signature: ["seq LAST", "seq FIRST LAST", "seq FIRST INCREMENT LAST"] 15 workson: [] 16 hugoversion: 17 relatedfuncs: [] 18 deprecated: false 19 draft: false 20 aliases: [] 21 --- 22 23 It's named and used in the model of [GNU's seq][]. 24 25 ``` 26 3 → 1, 2, 3 27 1 2 4 → 1, 3 28 -3 → -1, -2, -3 29 1 4 → 1, 2, 3, 4 30 1 -2 → 1, 0, -1, -2 31 ``` 32 33 ## Example: `seq` with `range` and `after` 34 35 You can use `seq` in combination with `range` and `after`. The following will return 19 elements: 36 37 ``` 38 {{ range after 1 (seq 20)}} 39 {{ end }} 40 ``` 41 42 However, when ranging with an index, the following may be less confusing in that `$indexStartingAt1` and `$num` will return `1,2,3 ... 20`: 43 44 ``` 45 {{ range $index, $num := (seq 20) }} 46 $indexStartingAt1 := (add $index 1) 47 {{ end }} 48 ``` 49 50 51 [GNU's seq]: http://www.gnu.org/software/coreutils/manual/html_node/seq-invocation.html#seq-invocation