{"id":17760784,"url":"https://github.com/alvii147/gloop","last_synced_at":"2025-05-12T18:50:17.310Z","repository":{"id":259557010,"uuid":"878207704","full_name":"alvii147/gloop","owner":"alvii147","description":"Go utility library for convenient looping using Go's range-over-func feature","archived":false,"fork":false,"pushed_at":"2024-11-15T15:57:44.000Z","size":315,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T01:44:37.457Z","etag":null,"topics":["golang"],"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/alvii147.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-25T00:47:27.000Z","updated_at":"2024-11-30T21:33:39.000Z","dependencies_parsed_at":"2024-10-26T13:59:42.133Z","dependency_job_id":"886be45c-83a4-42a6-b857-8e8aad6f5c9a","html_url":"https://github.com/alvii147/gloop","commit_stats":null,"previous_names":["alvii147/gloop"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvii147%2Fgloop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvii147%2Fgloop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvii147%2Fgloop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvii147%2Fgloop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alvii147","download_url":"https://codeload.github.com/alvii147/gloop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253804118,"owners_count":21967041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["golang"],"created_at":"2024-10-26T19:13:14.413Z","updated_at":"2025-05-12T18:50:16.722Z","avatar_url":"https://github.com/alvii147.png","language":"Go","readme":"[![Genocide Watch](https://hinds-banner.vercel.app/genocide-watch?variant=plum)](https://www.pcrf.net/)\n\n\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"gloop logo\" src=\"img/logo.svg\" width=500 /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003e\u003ci\u003egloop\u003c/i\u003e\u003c/strong\u003e is a Go utility library for convenient looping using Go's \u003ca href=\"https://go.dev/blog/range-functions\"\u003erange-over-func\u003c/a\u003e feature.\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/alvii147/gloop.svg)](https://pkg.go.dev/github.com/alvii147/gloop) [![Tests](https://img.shields.io/github/actions/workflow/status/alvii147/gloop/github-ci.yml?branch=main\u0026label=tests\u0026logo=github)](https://github.com/alvii147/gloop/actions) ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen) [![Go Report Card](https://goreportcard.com/badge/github.com/alvii147/gloop)](https://goreportcard.com/report/github.com/alvii147/gloop) [![License](https://img.shields.io/github/license/alvii147/gloop)](https://github.com/alvii147/gloop/blob/main/LICENSE)\n\n\u003c/div\u003e\n\n# Installation\n\nInstall `gloop` using the `go get` command:\n\n```bash\ngo get github.com/alvii147/gloop\n```\n\n\u003e [!NOTE]\n\u003e Go version 1.23+ required as older versions don't offer the range-over-func feature.\n\n# Usage\n\nOnce installed, `gloop` can be imported and used directly in your project:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/alvii147/gloop\"\n)\n\nfunc main() {\n\tfor seq := range gloop.Permutations(gloop.String(\"CAT\"), 3) {\n\t\tperm := gloop.ToString(seq)\n\t\tfmt.Println(perm)\n\t}\n}\n```\n\nThis ranges over and outputs all permutations of `CAT`:\n\n```\nCAT\nCTA\nACT\nATC\nTCA\nTAC\n```\n\nSee more specific documentation and examples in the [features section](#features) below.\n\n# Features\n\n## Generators\n\n* [`Interval`](https://pkg.go.dev/github.com/alvii147/gloop#Interval) allows looping over values in a given interval of a given step size. \n* [`Linspace`](https://pkg.go.dev/github.com/alvii147/gloop#Linspace) allows looping over evenly spaced values within a given interval. n must be greater than 1. \n* [`RandomNormal`](https://pkg.go.dev/github.com/alvii147/gloop#RandomNormal) allows looping over a given number of random values drawn from a Gaussian distribution. The size must not be negative and the standard deviation must be positive. \n* [`RandomUniform`](https://pkg.go.dev/github.com/alvii147/gloop#RandomUniform) allows looping over a given number of random values drawn from a uniform distribution. The size must not be negative. \n\n## Scalar Iterators\n\n* [`Chain`](https://pkg.go.dev/github.com/alvii147/gloop#Chain) allows looping over multiple [iter.Seq] sequences.\n* [`Chain2`](https://pkg.go.dev/github.com/alvii147/gloop#Chain2) allows looping over multiple [iter.Seq2] sequences.\n* [`Channel`](https://pkg.go.dev/github.com/alvii147/gloop#Channel) allows looping over values from a given channel. The values are consumed from the channel.\n* [`Collect`](https://pkg.go.dev/github.com/alvii147/gloop#Collect) allows looping over a given set of values.\n* [`Enumerate`](https://pkg.go.dev/github.com/alvii147/gloop#Enumerate) allows looping over an [iter.Seq] sequence with an index, converting it to an [iter.Seq2] sequence.\n* [`Filter`](https://pkg.go.dev/github.com/alvii147/gloop#Filter) runs a given function on each value from an [iter.Seq] sequence and allows looping over values for which the function returns true.\n* [`Filter2`](https://pkg.go.dev/github.com/alvii147/gloop#Filter2) runs a given function on each value from an [iter.Seq2] sequence and allows looping over values for which the function returns true.\n* [`Keys`](https://pkg.go.dev/github.com/alvii147/gloop#Keys) allows looping over an [iter.Seq2], converting it to an [iter.Seq] sequence by discarding the value.\n* [`KeyValue`](https://pkg.go.dev/github.com/alvii147/gloop#KeyValue) converts an [iter.Seq] sequence of [KeyValuePair] values to an [iter.Seq2] sequence.\n* [`KeyValue2`](https://pkg.go.dev/github.com/alvii147/gloop#KeyValue2) converts an [iter.Seq2] sequence to an [iter.Seq] sequence of [KeyValuePair] values.\n* [`List`](https://pkg.go.dev/github.com/alvii147/gloop#List) allows looping over a given [container/list.List].\n* [`Map`](https://pkg.go.dev/github.com/alvii147/gloop#Map) allows looping over keys and values in a map.\n* [`Reverse`](https://pkg.go.dev/github.com/alvii147/gloop#Reverse) allows looping over an [iter.Seq] sequence in order of descending index.\n* [`Reverse2`](https://pkg.go.dev/github.com/alvii147/gloop#Reverse2) allows looping over an [iter.Seq2] sequence in order of descending index.\n* [`Slice`](https://pkg.go.dev/github.com/alvii147/gloop#Slice) allows looping over a given slice.\n* [`Sort`](https://pkg.go.dev/github.com/alvii147/gloop#Sort) allows looping over an [iter.Seq] sequence in sorted order.\n* [`SortByComparison`](https://pkg.go.dev/github.com/alvii147/gloop#SortByComparison) allows looping over an [iter.Seq] sequence in sorted order using a comparison function.\n* [`SortByComparison2`](https://pkg.go.dev/github.com/alvii147/gloop#SortByComparison2) allows looping over an [iter.Seq2] sequence in sorted order using a comparison function.\n* [`SortByRank`](https://pkg.go.dev/github.com/alvii147/gloop#SortByRank) allows looping over an [iter.Seq] sequence in sorted order using a ranking function.\n* [`SortByRank2`](https://pkg.go.dev/github.com/alvii147/gloop#SortByRank2) allows looping over an [iter.Seq2] sequence in sorted order using a ranking function.\n* [`String`](https://pkg.go.dev/github.com/alvii147/gloop#String) allows looping over the runes in a given string.\n* [`Transform`](https://pkg.go.dev/github.com/alvii147/gloop#Transform) runs a given function on each value over an [iter.Seq] sequence and allows looping over the returned values.\n* [`Transform2`](https://pkg.go.dev/github.com/alvii147/gloop#Transform2) runs a given function on each key and value over an [iter.Seq2] sequence and allows looping over the returned values.\n* [`Values`](https://pkg.go.dev/github.com/alvii147/gloop#Values) allows looping over an [iter.Seq2] and converting it to an [iter.Seq] sequence by discarding the key.\n* [`Zip`](https://pkg.go.dev/github.com/alvii147/gloop#Zip) allows looping over two [iter.Seq] sequences in pairs.\n* [`Zip2`](https://pkg.go.dev/github.com/alvii147/gloop#Zip2) allows looping over two [iter.Seq2] sequences in pairs.\n\n## Vector Iterators\n\n* [`Batch`](https://pkg.go.dev/github.com/alvii147/gloop#Batch) allows looping over an [iter.Seq] sequence in batches of a given size. The batch size must be positive.\n* [`Batch2`](https://pkg.go.dev/github.com/alvii147/gloop#Batch2) allows looping over an [iter.Seq2] sequence in batches of a given size. The batch size must be positive.\n* [`CartesianProduct`](https://pkg.go.dev/github.com/alvii147/gloop#CartesianProduct) allows looping over the Cartesian product of a given size for an [iter.Seq] sequence. The size must be positive.\n* [`CartesianProduct2`](https://pkg.go.dev/github.com/alvii147/gloop#CartesianProduct2) allows looping over the Cartesian product of a given size for an [iter.Seq2] sequence. The size must be positive.\n* [`Combinations`](https://pkg.go.dev/github.com/alvii147/gloop#Combinations) allows looping over all combinations of a given size for an [iter.Seq] sequence. The size must be positive.\n* [`Combinations2`](https://pkg.go.dev/github.com/alvii147/gloop#Combinations2) allows looping over all combinations of a given size for an [iter.Seq2] sequence. The size must be positive.\n* [`Permutations`](https://pkg.go.dev/github.com/alvii147/gloop#Permutations) allows looping over all permutations of a given size for an [iter.Seq] sequence. The size must be positive.\n* [`Permutations2`](https://pkg.go.dev/github.com/alvii147/gloop#Permutations2) allows looping over all permutations of a given size for an [iter.Seq2] sequence. The size must be positive.\n* [`Window`](https://pkg.go.dev/github.com/alvii147/gloop#Window) allows looping over an [iter.Seq] sequence in sliding windows of a given size.\n* [`Window2`](https://pkg.go.dev/github.com/alvii147/gloop#Window2) allows looping over an [iter.Seq2] sequence in sliding windows of a given size.\n* [`ZipN`](https://pkg.go.dev/github.com/alvii147/gloop#ZipN) allows looping over multiple [iter.Seq] sequences simultaneously.\n* [`ZipN2`](https://pkg.go.dev/github.com/alvii147/gloop#ZipN2) allows looping over multiple [iter.Seq2] sequences simultaneously.\n\n## Aggregators\n\n* [`All`](https://pkg.go.dev/github.com/alvii147/gloop#All) computes whether or not all values in an [iter.Seq] sequence are true.\n* [`Any`](https://pkg.go.dev/github.com/alvii147/gloop#Any) computes whether or not any value in an [iter.Seq] sequence is true.\n* [`Equal`](https://pkg.go.dev/github.com/alvii147/gloop#Equal) checks if two given [iter.Seq] sequences are exactly equal in contents and order.\n* [`Equal2`](https://pkg.go.dev/github.com/alvii147/gloop#Equal2) checks if two given [iter.Seq2] sequences are exactly equal in contents and order.\n* [`Equivalent`](https://pkg.go.dev/github.com/alvii147/gloop#Equivalent) checks if two given [iter.Seq] sequences are equal in contents, ignoring order.\n* [`Equivalent2`](https://pkg.go.dev/github.com/alvii147/gloop#Equivalent2) checks if two given [iter.Seq2] sequences are equal in contents, ignoring order.\n* [`Fold`](https://pkg.go.dev/github.com/alvii147/gloop#Fold) runs a given function on each value from an [iter.Seq] sequence and accumulates the result into a single value.\n* [`Fold2`](https://pkg.go.dev/github.com/alvii147/gloop#Fold2) runs a given function on each value from an [iter.Seq2] sequence and accumulates the result into a single value.\n* [`Max`](https://pkg.go.dev/github.com/alvii147/gloop#Max) computes the maximum value over an [iter.Seq] sequence.\n* [`MaxByComparison`](https://pkg.go.dev/github.com/alvii147/gloop#MaxByComparison) computes the maximum value over an [iter.Seq] sequence using a comparison function.\n* [`MaxByComparison2`](https://pkg.go.dev/github.com/alvii147/gloop#MaxByComparison2) computes the maximum key and value over an [iter.Seq2] sequence using a comparison function.\n* [`MaxByRank`](https://pkg.go.dev/github.com/alvii147/gloop#MaxByRank) computes the maximum value over an [iter.Seq] sequence using a ranking function.\n* [`MaxByRank2`](https://pkg.go.dev/github.com/alvii147/gloop#MaxByRank2) computes the maximum value over an [iter.Seq2] sequence using a ranking function.\n* [`Mean`](https://pkg.go.dev/github.com/alvii147/gloop#Mean) computes the mean value over an [iter.Seq] sequence.\n* [`Min`](https://pkg.go.dev/github.com/alvii147/gloop#Min) computes the minimum value over an [iter.Seq] sequence.\n* [`MinByComparison`](https://pkg.go.dev/github.com/alvii147/gloop#MinByComparison) computes the minimum value over an [iter.Seq] sequence using a comparison function.\n* [`MinByComparison2`](https://pkg.go.dev/github.com/alvii147/gloop#MinByComparison2) computes the minimum key and value over an [iter.Seq2] sequence using a comparison function.\n* [`MinByRank`](https://pkg.go.dev/github.com/alvii147/gloop#MinByRank) computes the minimum value over an [iter.Seq] sequence using a ranking function.\n* [`MinByRank2`](https://pkg.go.dev/github.com/alvii147/gloop#MinByRank2) computes the minimum value over an [iter.Seq2] sequence using a ranking function.\n* [`Product`](https://pkg.go.dev/github.com/alvii147/gloop#Product) computes the product of values over an [iter.Seq] sequence.\n* [`Reduce`](https://pkg.go.dev/github.com/alvii147/gloop#Reduce) runs a given function on each adjacent pair in an [iter.Seq] sequence and accumulates the result into a single value.\n* [`Reduce2`](https://pkg.go.dev/github.com/alvii147/gloop#Reduce2) runs a given function on each adjacent pair of keys and values in an [iter.Seq2] sequence and accumulates the result into a single key and value pair.\n* [`Sum`](https://pkg.go.dev/github.com/alvii147/gloop#Sum) computes summation over an [iter.Seq] sequence.\n* [`ToList`](https://pkg.go.dev/github.com/alvii147/gloop#ToList) converts an [iter.Seq] sequence to a [container/list.List].\n* [`ToList2`](https://pkg.go.dev/github.com/alvii147/gloop#ToList2) converts an [iter.Seq2] sequence to [container/list.List] of keys and values.\n* [`ToSlice`](https://pkg.go.dev/github.com/alvii147/gloop#ToSlice) converts an [iter.Seq] sequence to a slice.\n* [`ToSlice2`](https://pkg.go.dev/github.com/alvii147/gloop#ToSlice2) converts an [iter.Seq2] sequence to slices of keys and values.\n* [`ToString`](https://pkg.go.dev/github.com/alvii147/gloop#ToString) converts an [iter.Seq] sequence of runes to a string.\n\n## Miscellaneous\n\n* [`DeferLoop`](https://pkg.go.dev/github.com/alvii147/gloop#DeferLoop) allows looping over an [iter.Seq] sequence, yielding a defer function that can register another function to be executed at the end of the currently running loop. If multiple functions are registered, they are executed in FIFO order.\n* [`Parallelize`](https://pkg.go.dev/github.com/alvii147/gloop#Parallelize) runs a function on each value in an [iter.Seq] sequence on separate goroutines.\n* [`Parallelize2`](https://pkg.go.dev/github.com/alvii147/gloop#Parallelize2) runs a function on each value in an [iter.Seq2] sequence on separate goroutines.\n\n[iter.Seq]: https://pkg.go.dev/iter#Seq\n[iter.Seq2]: https://pkg.go.dev/iter#Seq2\n[container/list.List]: https://pkg.go.dev/container/list#List\n\n# Contributing\n\nAll contributions are welcome! Please see [CONTRIBUTING.md](.github/CONTRIBUTING.md) for contribution guidelines.\n","funding_links":[],"categories":["Data Structures and Algorithms","数据结构与算法","Data Integration Frameworks"],"sub_categories":["Iterators","迭代器"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvii147%2Fgloop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falvii147%2Fgloop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvii147%2Fgloop/lists"}