{"id":37092067,"url":"https://github.com/orangootan/go-seq","last_synced_at":"2026-01-14T11:12:47.549Z","repository":{"id":62916624,"uuid":"563364702","full_name":"orangootan/go-seq","owner":"orangootan","description":"Golang implementation of generic lazily iterated sequences.","archived":false,"fork":false,"pushed_at":"2022-11-08T14:49:11.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-20T01:59:37.605Z","etag":null,"topics":["go","go-library","go-module","go-package","golang","iterable","iterator","sequence"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orangootan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-08T13:14:15.000Z","updated_at":"2022-11-22T11:20:33.000Z","dependencies_parsed_at":"2022-11-09T04:01:24.956Z","dependency_job_id":null,"html_url":"https://github.com/orangootan/go-seq","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/orangootan/go-seq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangootan%2Fgo-seq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangootan%2Fgo-seq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangootan%2Fgo-seq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangootan%2Fgo-seq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orangootan","download_url":"https://codeload.github.com/orangootan/go-seq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangootan%2Fgo-seq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28418015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","go-library","go-module","go-package","golang","iterable","iterator","sequence"],"created_at":"2026-01-14T11:12:46.937Z","updated_at":"2026-01-14T11:12:47.540Z","avatar_url":"https://github.com/orangootan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-pink.svg)](https://opensource.org/licenses/MIT)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/orangootan/go-seq)]()\n[![Release](https://img.shields.io/github/release/orangootan/go-seq)](https://github.com/orangootan/go-seq/releases/latest)\n[![GoDoc](https://godoc.org/github.com/orangootan/go-seq?status.svg)](https://godoc.org/github.com/orangootan/go-seq)\n[![Go Report Card](https://goreportcard.com/badge/github.com/orangootan/go-seq)](https://goreportcard.com/report/github.com/orangootan/go-seq)\n[![CodeFactor](https://www.codefactor.io/repository/github/orangootan/go-seq/badge)](https://www.codefactor.io/repository/github/orangootan/go-seq)\n![Test](https://github.com/orangootan/go-seq/actions/workflows/test.yml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/orangootan/go-seq/badge.svg?branch=main)](https://coveralls.io/github/orangootan/go-seq?branch=main)\n[![codecov](https://codecov.io/gh/orangootan/go-seq/branch/main/graph/badge.svg?token=zSDhAPZQe2)](https://codecov.io/gh/orangootan/go-seq)\n## go-seq\nGolang implementation of generic lazily iterated sequences.  \nRequires Go 1.18+.\n## Package\n```go\nimport \"github.com/orangootan/go-seq/pkg/seq\"\n```\nAll examples use unqualified import as if:\n```go\nimport . \"github.com/orangootan/go-seq/pkg/seq\"\n```\n## Examples\n### Seq[T]\n**Seq[T]** is the main interface declaring methods for working with sequences. Some functions are implemented as standalone functions (not methods of this interface) due to limitations of Go generics implementation.\n### FromSlice\n**FromSlice()** returns a sequence of items from the given slice.  \nSee further examples.\n### Iterator\n**Iterator()** returns iterator object of a sequence.  \n**Next()** advances iterator to the next item of the iterated sequence. Returns true if successfully advanced or false if passed the end of the sequence.  \n**Current()** returns pointer to the current item of the iterated sequence.\n```go\ns := []int{1, 2, 3}\nit := FromSlice(s).Iterator()\nfor it.Next() {\n    fmt.Println(*it.Current())\n}\n// Output:\n// 1\n// 2\n// 3\n```\n### AsSlice\n**AsSlice()** collects all sequence items into newly created slice.  \nSee further examples.\n### FromSliceReversed\n**FromSliceReversed()** returns a sequence of items from the given slice in inverted order.\n```go\ns := FromSliceReversed([]int{1, 2, 3, 4})\nfmt.Println(s.AsSlice())\n// Output:\n// [4 3 2 1]\n```\n### FromChan\n**FromChan()** returns a sequence of items received from a channel until the channel is closed.\n```go\nch := make(chan int)\ngo func() {\n    ch \u003c- 1\n    ch \u003c- 2\n    ch \u003c- 3\n    close(ch)\n}()\nfmt.Println(FromChan(ch).AsSlice())\n// Output:\n// [1 2 3]\n```\n### Generate\n**Generate()** returns an infinite sequence applying a mapping function to item indices.\n```go\ns := Generate(func(i int) int { return i * i })\nfmt.Println(s.Take(6).AsSlice())\n// Output:\n// [0 1 4 9 16 25]\n```\n### Iterate\n**Iterate()** returns an infinite sequence consisting of seed, fn(seed), fn(fn(seed)), etc.\n```go\ns := Iterate(2, func(i int) int { return 2 * i })\nfmt.Println(s.Take(8).AsSlice())\n// Output:\n// [2 4 8 16 32 64 128 256]\n```\n### Cycle\n**Cycle()** returns an infinite sequence by cycling items from the given slice.\n```go\ns := []int{1, 2, 3}\nr := Cycle(s).Take(9)\nfmt.Println(r.AsSlice())\n// Output:\n// [1 2 3 1 2 3 1 2 3]\n```\n### Repeat\n**Repeat()** returns an infinite sequence repeating the given item.\n```go\ns := Repeat(1).Take(5)\nfmt.Println(s.AsSlice())\n// Output:\n// [1 1 1 1 1]\n```\n### Single\n// Single returns a sequence containing exactly one specified item.\n```go\ns := Single(3)\nfmt.Println(s.AsSlice())\nfmt.Println(s.Count())\n// Output:\n// [3]\n// 1\n```\n### Empty\n**Empty()** returns empty sequence.\n```go\nfmt.Println(Empty[int]().Count())\nfmt.Println(Empty[string]().AsSlice())\nfmt.Println(Empty[int]().IsEmpty())\nit := Empty[int]().Iterator()\nfmt.Println(it.Next(), it.Current())\n// Output:\n// 0\n// []\n// true\n// false \u003cnil\u003e\n```\n### IsEmpty\n**IsEmpty()** determines whether a sequence is empty.\n```go\ns1 := []int{1, 2, 3}\nvar s2 []int\nfmt.Println(FromSlice(s1).IsEmpty())\nfmt.Println(FromSlice(s2).IsEmpty())\nfmt.Println(Empty[int]().IsEmpty())\n// Output:\n// false\n// true\n// true\n```\n### Equal\n**Equal()** determines whether two sequences have equal length and equal corresponding items. This function works only with sequences of comparable items.\n```go\ns1 := FromSlice([]int{1, 2, 3, 4})\ns2 := FromSlice([]int{1, 2, 3})\ns3 := FromSlice([]int{0, 1, 2})\ns4 := FromSlice([]int{0, 1, 2})\nfmt.Println(Equal(s1, s2))\nfmt.Println(Equal(s2, s3))\nfmt.Println(Equal(s3, s4))\n// Output:\n// false\n// false\n// true\n```\n### Concat\n**Concat()** concatenates two sequences.\n```go\ns1 := FromSlice([]int{1, 2, 3, 4})\ns2 := FromSlice([]int{5, 6, 7})\nr := s1.Concat(s2)\nfmt.Println(r.AsSlice())\n// Output:\n// [1 2 3 4 5 6 7]\n```\n### Cycled\n**Cycled()** repeats a sequence infinitely.\n```go\ns := []int{1, 2, 3}\nr := FromSlice(s).Cycled().Take(10)\nfmt.Println(r.AsSlice())\n// Output:\n// [1 2 3 1 2 3 1 2 3 1]\n```\n### Filter (Where)\n**Filter()** filters a sequence of items based on the given predicate.  \n**Where()** is an alias for **Filter()**. Use whatever name you like.\n```go\nisEven := func(i int) bool { return i%2 == 0 }\ns := []int{1, 2, 3, 4, 5, 6}\nr := FromSlice(s).Filter(isEven)\nfmt.Println(r.AsSlice())\n// Output:\n// [2 4 6]\n```\n### Reverse\n**Reverse()** inverts the order of items in a sequence.\n```go\ns := []int{1, 2, 3, 4, 5, 6}\nr := FromSlice(s).Reverse()\nfmt.Println(r.AsSlice())\n// Output:\n// [6 5 4 3 2 1]\n```\n### Skip\n**Skip()** bypasses the given number of items in a sequence and then returns the remaining items.\n```go\ns := []int{1, 2, 3, 4, 5, 6}\nr := FromSlice(s).Skip(3)\nfmt.Println(r.AsSlice())\n// Output:\n// [4 5 6]\n```\n### SkipWhile\n**SkipWhile()** bypasses items in a sequence as long as the given condition is true and then returns the remaining items.\n```go\nlessThan5 := func(i int) bool { return i \u003c 5 }\ns1 := []int{1, 2, 3, 4, 5, 6, 1}\ns2 := []int{1, 2, 3}\nr1 := FromSlice(s1).SkipWhile(lessThan5)\nr2 := FromSlice(s2).SkipWhile(lessThan5)\nfmt.Println(r1.AsSlice())\nfmt.Println(r2.AsSlice())\n// Output:\n// [5 6 1]\n// []\n```\n### Take\n**Take()** returns the given number of items from the start of a sequence.\n```go\ns := []int{1, 2, 3, 4, 5, 6}\nr := FromSlice(s).Take(4)\nfmt.Println(r.AsSlice())\n// Output:\n// [1 2 3 4]\n```\n### TakeWhile\n**TakeWhile()** returns items from a sequence as long as the given condition is true, and then skips the remaining items.\n```go\nlessThan5 := func(i int) bool { return i \u003c 5 }\ns := []int{1, 2, 3, 4, 5, 6, 1}\nr := FromSlice(s).TakeWhile(lessThan5)\nfmt.Println(r.AsSlice())\n// Output:\n// [1 2 3 4]\n```\n### Interleave\n**Interleave()** returns a sequence that interleaves items from two sequences.\n```go\ns1 := FromSlice([]int{1, 2, 3, 4})\ns2 := FromSlice([]int{4, 5, 6})\nr := s1.Interleave(s2)\nfmt.Println(r.AsSlice())\n// Output:\n// [1 4 2 5 3 6 4]\n```\n### Map (Select)\n**Map()** projects items of a sequence using the given function.  \n**Select()** is an alias for **Map()**. Use whatever name you like.\n```go\ns := FromSlice([]int{1, 2, 3, 4, 5, 6})\nr := Map(s, func(i int) int { return i * i })\nfmt.Println(r.AsSlice())\n// Output:\n// [1 4 9 16 25 36]\n```\n### Zip\n**Zip()** combines items of two sequences pairwise using a projection function.\n```go\ns1 := FromSlice([]int{1, 2, 3})\ns2 := FromSlice([]int{4, 5, 6, 7})\nr := Zip(s1, s2, func(u int, v int) [2]int {\n    return [2]int{u, v}\n})\nfmt.Println(r.AsSlice())\n// Output:\n// [[1 4] [2 5] [3 6]]\n```\n### Zip3\n**Zip3()** is same as Zip but combines three sequences.\n```go\ns1 := FromSlice([]int{1, 2, 3})\ns2 := FromSlice([]int{4, 5, 6})\ns3 := FromSlice([]int{7, 8, 9, 10})\nr := Zip3(s1, s2, s3, func(u int, v int, w int) [3]int {\n    return [3]int{u, v, w}\n})\nfmt.Println(r.AsSlice())\n// Output:\n// [[1 4 7] [2 5 8] [3 6 9]]\n```\n### All\n**All()** determines whether all items of a sequence satisfy the given condition.\n```go\nisEven := func(i int) bool { return i%2 == 0 }\ns1 := []int{2, 4, 6, 8, 10}\ns2 := []int{2, 4, 6, 8, 11}\nfmt.Println(FromSlice(s1).All(isEven))\nfmt.Println(FromSlice(s2).All(isEven))\n// Output:\n// true\n// false\n```\n### Any\n**Any()** determines whether any item of a sequence satisfies the given condition.\n```go\nisEven := func(i int) bool { return i%2 == 0 }\ns1 := []int{1, 3, 5, 7, 10}\ns2 := []int{1, 3, 5, 7, 9}\nfmt.Println(FromSlice(s1).Any(isEven))\nfmt.Println(FromSlice(s2).Any(isEven))\n// Output:\n// true\n// false\n```\n### Chunk\n**Chunk()** splits a sequence into chunks of the given size and returns sequence of slices.\n```go\ns := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}\nr := Chunk(3, FromSlice(s))\nfmt.Println(r.AsSlice())\n// Output:\n// [[1 2 3] [4 5 6] [7 8 9] [10 11]]\n```\n### Contains\n**Contains()** determines whether a sequence contains the given item. This function works only with sequences of comparable items.\n```go\ns := FromSlice([]int{1, 2, 3, 4, 5})\nfmt.Println(Contains(3, s))\nfmt.Println(Contains(6, s))\n// Output:\n// true\n// false\n```\n### Count (method)\n**Count()** counts number of items in a sequence.\n```go\ns1 := []int{1, 2, 3, 4, 5}\nvar s2 []int\nfmt.Println(FromSlice(s1).Count())\nfmt.Println(FromSlice(s2).Count())\n// Output:\n// 5\n// 0\n```\n### Count (function)\n**Count()** counts number of items in a sequence. You can specify an integer type for result.\n```go\ns := []string{\"Huey\", \"Dewey\", \"Louie\"}\nc := Count[string, uint64](FromSlice(s))\nfmt.Printf(\"%T %v\", c, c)\n// Output:\n// uint64 3\n```\n### Distinct\n**Distinct()** returns distinct elements from a sequence. This function works only with sequences of comparable items.\n```go\ns := []int{2, 2, 3, 1, 2, 3}\nr := Distinct(FromSlice(s))\nfmt.Println(r.AsSlice())\n// Output:\n// [2 3 1]\n```\n### First\n**First()** returns undefined value and false if a sequence is empty or the first item and true otherwise.\n```go\ns1 := []int{1, 2, 3}\nvar s2 []int\nfmt.Println(FromSlice(s1).First())\nfmt.Println(FromSlice(s2).First())\n// Output:\n// 1 true\n// 0 false\n```\n### FirstOrDefault\n**FirstOrDefault()** returns default value of type T if a sequence is empty or the first item otherwise.\n```go\ns1 := []int{1, 2, 3}\nvar s2 []int\nfmt.Println(FromSlice(s1).FirstOrDefault())\nfmt.Println(FromSlice(s2).FirstOrDefault())\n// Output:\n// 1\n// 0\n```\n### Flatten\n**Flatten()** combines a sequence of item sequences into flat sequence of items.\n```go\ns1 := FromSlice([]int{1, 2, 3})\ns2 := FromSlice([]int{4, 5, 6})\ns3 := FromSlice([]int{7, 8, 9})\nss := FromSlice([]Seq[int]{s1, s2, s3})\nfmt.Println(Flatten(ss).AsSlice())\n// Output:\n// [1 2 3 4 5 6 7 8 9]\n```\n### FlatMap\n**FlatMap()** maps each sequence item to a sequence and flattens results.\n```go\ns := []int{1, 2, 3}\nr := FlatMap(FromSlice(s), func(i int) Seq[int] {\n    return Repeat(i).Take(i)\n})\nfmt.Println(r.AsSlice())\n// Output:\n// [1 2 2 3 3 3]\n```\n### Reduce\n**Reduce()** applies an accumulator function over a sequence given a specified initial value.\n```go\nsum := func(a int, b int) int { return a + b }\ns1 := []int{1, 2, 3, 4, 5}\nvar s2 []int\nfmt.Println(FromSlice(s1).Reduce(0, sum))\nfmt.Println(FromSlice(s2).Reduce(0, sum))\n// Output:\n// 15\n// 0\n```\n### Fold\n**Fold()** applies an accumulator function over a sequence given a specified initial value. Accumulator and item types can be different.\n```go\nsum := func(a int, b int) int { return a + b }\nappendInt := func(s []int, i int) []int {\n    return append(s, i)\n}\ns := FromSlice([]int{1, 2, 3})\nfmt.Println(Fold(s, 0, sum))\nfmt.Println(Fold(s, []int{4, 5}, appendInt))\n// Output:\n// 6\n// [4 5 1 2 3]\n```\n### ForEach\n**ForEach()** performs an action for each item in a sequence.\n```go\ns := []string{\"Huey\", \"Dewey\", \"Louie\"}\nFromSlice(s).ForEach(func(name string) {\n    fmt.Println(name)\n})\n// Output:\n// Huey\n// Dewey\n// Louie\n```\n### ForEnumerated\n**ForEnumerated()** is similar to ForEach but passes item index as first parameter of action function.\n```go\ns := []string{\"Huey\", \"Dewey\", \"Louie\"}\nFromSlice(s).ForEnumerated(func(i int, name string) {\n    fmt.Println(i, name)\n})\n// Output:\n// 0 Huey\n// 1 Dewey\n// 2 Louie\n```\n### GroupBy\n**GroupBy()** returns a map grouping sequence items by key produced by the given function. Key type must be comparable.\n```go\nisEven := func(i int) bool { return i%2 == 0 }\ns := []int{1, 2, 3, 4, 5, 6}\ng := GroupBy(FromSlice(s), isEven)\nfor k, v := range g {\n    fmt.Printf(\"%v: %v\\n\", k, v)\n}\n// Unordered output:\n// false: [1 3 5]\n// true: [2 4 6]\n```\n### Inspect\n**Inspect()** allows to observe items of a sequence by performing an action for each item.\n```go\nisEven := func(i int) bool { return i%2 == 0 }\nFromSlice([]int{1, 2, 3}).\n    Inspect(func(i int) {\n        fmt.Printf(\"before: %v\\n\", i)\n    }).\n    Filter(isEven).\n    Inspect(func(i int) {\n        fmt.Printf(\"after: %v\\n\", i)\n    }).\n    Count()\n// Output:\n// before: 1\n// before: 2\n// after: 2\n// before: 3\n```\n### Partition\n**Partition()** returns two slices. The first one contains items satisfying the given condition, the second one contains the rest of them.\n```go\ns := FromSlice([]int{1, 2, 3, 4, 5, 6})\nt, f := s.Partition(func(i int) bool { return i%2 == 0 })\nfmt.Println(t)\nfmt.Println(f)\n// Output:\n// [2 4 6]\n// [1 3 5]\n```\n### Sum\n**Sum()** returns sum of elements in a sequence. This function works with sequences of numbers.\n```go\ns1 := []int{1, 2, 3, 4}\nvar s2 []int\nfmt.Println(Sum(FromSlice(s1)))\nfmt.Println(Sum(FromSlice(s2)))\n// Output:\n// 10\n// 0\n```\n### Product\n**Product()** returns product of elements in a sequence. This function works with sequences of numbers.\n```go\ns1 := []int{1, 2, 3, 4}\nvar s2 []int\nfmt.Println(Product(FromSlice(s1)))\nfmt.Println(Product(FromSlice(s2)))\n// Output:\n// 24\n// 1\n```\n### Average\n**Average()** returns average number of a sequence of numbers. This function works with sequences of integer and float numbers.\n```go\ns1 := []int{1, 2, 3, 4, 5}\nfmt.Println(Average(FromSlice(s1)))\n// Output:\n// 3\n```\n### Max\n**Max()** returns the maximum element of a sequence and true if the sequence is not empty or undefined value and false otherwise.  This function works with sequences of integer numbers, float numbers and strings.\n```go\ns1 := []int{1, 2, 3}\ns2 := []string{\"Huey\", \"Dewey\", \"Louie\"}\nvar s3 []int\nfmt.Println(Max(FromSlice(s1)))\nfmt.Println(Max(FromSlice(s2)))\nfmt.Println(Max(FromSlice(s3)))\n// Output:\n// 3 true\n// Louie true\n// 0 false\n```\n### Min\n**Min()** returns the minimum element of a sequence and true if the sequence is not empty or undefined value and false otherwise. This function works with sequences of integer numbers, float numbers and strings.\n```go\ns1 := []int{1, 2, 3}\ns2 := []string{\"Huey\", \"Dewey\", \"Louie\"}\nvar s3 []int\nfmt.Println(Min(FromSlice(s1)))\nfmt.Println(Min(FromSlice(s2)))\nfmt.Println(Min(FromSlice(s3)))\n// Output:\n// 1 true\n// Dewey true\n// 0 false\n```\n### AsChan\n**AsChan()** creates a channel and sends all sequence items into it in separate goroutine. After the sequence exhausted the channel is closed. You can specify the channel capacity with cap parameter.\n```go\nch := FromSlice([]int{1, 2, 3}).AsChan(0)\nfor i := range ch {\n    fmt.Println(i)\n}\n// Output:\n// 1\n// 2\n// 3\n```\n### ToChan\n**ToChan()** sends sequence items to an existing channel in current goroutine so this call is blocking. This function does not close the channel after the sequence is exhausted.\n```go\nch := make(chan int)\ngo func() {\n    FromSlice([]int{1, 2}).ToChan(ch)\n    FromSlice([]int{3, 4}).ToChan(ch)\n    close(ch)\n}()\nfor i := range ch {\n    fmt.Println(i)\n}\n// Output:\n// 1\n// 2\n// 3\n// 4\n```\n### ToSlice\n**ToSlice()** appends items of a sequence to an existing slice given by reference.\n```go\ns1 := []int{1, 2}\ns2 := []int{3, 4, 5}\nFromSlice(s2).ToSlice(\u0026s1)\nfmt.Println(s1)\n// Output:\n// [1 2 3 4 5]\n```\n### FilterP (WhereP)\n**FilterP()** filters a sequence of items based on the given predicate.  \nThis is parallel version of **Filter()** using specified number of goroutines to process items in parallel.\n**WhereP()** is an alias for **FilterP()**. Use whatever name you like.\n```go\nisEven := func(i int) bool {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return i%2 == 0\n}\ns := []int{1, 2, 3, 4, 5, 6}\nFromSlice(s).FilterP(2, isEven).ForEach(func(i int) {\n    fmt.Println(i)\n})\n// Unordered output:\n// 2\n// 4\n// 6\n```\n### MapP (SelectP)\n**MapP()** projects items of a sequence using the given function.  \nThis is parallel version of **Map()** using specified number of goroutines to process items in parallel.\n**SelectP()** is an alias for **MapP()**. Use whatever name you like.\n```go\ns := FromSlice([]int{1, 2, 3, 4, 5, 6})\nMapP(2, s, func(i int) int {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return i * i\n}).ForEach(func(i int) {\n    fmt.Println(i)\n})\n// Unordered output:\n// 1\n// 4\n// 9\n// 16\n// 25\n// 36\n```\n### FlatmapP\n**FlatMapP()** maps each sequence item to a sequence and flattens results.  \nThis is parallel version of **FlatMap()** using specified number of goroutines to process items in parallel.\n```go\ns := FromSlice([]int{1, 2, 3})\nFlatMapP(2, s, func(i int) Seq[int] {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return Repeat(i).Take(i)\n}).ForEach(func(i int) {\n    fmt.Println(i)\n})\n// Unordered output:\n// 1\n// 2\n// 2\n// 3\n// 3\n// 3\n```\n### ReduceP\n**ReduceP()** applies an accumulator function over a sequence given a specified initial value.  \nThis is parallel version of **Reduce()** using specified number of goroutines to process items in parallel.\n```go\nsum := func(a int, b int) int {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return a + b\n}\ns1 := []int{1, 2, 3, 4, 5}\nvar s2 []int\nfmt.Println(FromSlice(s1).ReduceP(2, 0, sum))\nfmt.Println(FromSlice(s2).ReduceP(2, 0, sum))\n// Output:\n// 15\n// 0\n```\n### ForEachP\n**ForEachP()** performs an action for each item in a sequence.  \nThis is parallel version of **ForEach()** using specified number of goroutines to process items in parallel.\n```go\ns := []string{\"Huey\", \"Dewey\", \"Louie\"}\nFromSlice(s).ForEachP(2, func(name string) {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    fmt.Println(name)\n})\n// Unordered output:\n// Huey\n// Dewey\n// Louie\n```\n### ForEnumeratedP\n**ForEnumeratedP()** is similar to **ForEachP()** but passes item index as first parameter of action function.  \nThis is parallel version of **ForEnumerated()** using specified number of goroutines to process items in parallel.\n```go\ns := []string{\"Huey\", \"Dewey\", \"Louie\"}\nFromSlice(s).ForEnumeratedP(2, func(i int, name string) {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    fmt.Println(i, name)\n})\n// Unordered output:\n// 0 Huey\n// 1 Dewey\n// 2 Louie\n```\n### AllP\n**AllP()** determines whether all items of a sequence satisfy the given condition.  \nThis is parallel version of **All()** using specified number of goroutines to process items in parallel.\n```go\nisEven := func(i int) bool {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return i%2 == 0\n}\ns1 := []int{2, 4, 6, 8, 10, 12, 14, 16}\ns2 := []int{2, 4, 6, 8, 11, 12, 14, 16}\nfmt.Println(FromSlice(s1).AllP(2, isEven))\nfmt.Println(FromSlice(s2).AllP(2, isEven))\n// Output:\n// true\n// false\n```\n### AnyP\n**AnyP()** determines whether any item of a sequence satisfies the given condition.  \nThis is parallel version of **Any()** using specified number of goroutines to process items in parallel.\n```go\nisEven := func(i int) bool {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return i%2 == 0\n}\ns1 := []int{1, 3, 5, 7, 9, 11, 13, 15}\ns2 := []int{1, 2, 4, 7, 9, 11, 13, 16}\nfmt.Println(FromSlice(s1).AnyP(2, isEven))\nfmt.Println(FromSlice(s2).AnyP(2, isEven))\n// Output:\n// false\n// true\n```\n### PartitionP\n**PartitionP()** returns two slices. The first one contains items satisfying the given condition, the second one contains the rest of them.  \nThis is parallel version of **Partition()** using specified number of goroutines to process items in parallel.\n```go\ns := FromSlice([]int{1, 2, 3, 4, 5, 6})\nt, f := s.PartitionP(1, func(i int) bool {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return i%2 == 0\n})\nfor _, i := range t {\n    fmt.Println(\"even:\", i)\n}\nfor _, i := range f {\n    fmt.Println(\"odd:\", i)\n}\n// Unordered output:\n// even: 2\n// even: 4\n// even: 6\n// odd: 1\n// odd: 3\n// odd: 5\n```\n### ZipP\n**ZipP()** combines items of two sequences pairwise using a projection function.  \nThis is parallel version of **Zip()** using specified number of goroutines to process items in parallel.\n```go\ns1 := FromSlice([]int{1, 2, 3})\ns2 := FromSlice([]int{4, 5, 6, 7})\nZipP(2, s1, s2, func(u int, v int) [2]int {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return [2]int{u, v}\n}).ForEach(func(s [2]int) {\n    fmt.Println(s)\n})\n// Unordered output:\n// [1 4]\n// [2 5]\n// [3 6]\n```\n### Zip3P\n**Zip3P()** is same as **ZipP()** but combines three sequences.  \nThis is parallel version of **Zip3()** using specified number of goroutines to process items in parallel.\n```go\ns1 := FromSlice([]int{1, 2, 3})\ns2 := FromSlice([]int{4, 5, 6})\ns3 := FromSlice([]int{7, 8, 9, 10})\nZip3P(2, s1, s2, s3, func(u int, v int, w int) [3]int {\n    time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)\n    return [3]int{u, v, w}\n}).ForEach(func(s [3]int) {\n    fmt.Println(s)\n})\n// Unordered output:\n// [1 4 7]\n// [2 5 8]\n// [3 6 9]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forangootan%2Fgo-seq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forangootan%2Fgo-seq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forangootan%2Fgo-seq/lists"}