{"id":22870270,"url":"https://github.com/berquerant/circle","last_synced_at":"2025-03-31T11:26:08.450Z","repository":{"id":57534124,"uuid":"279946849","full_name":"berquerant/circle","owner":"berquerant","description":"stream library for Go","archived":false,"fork":false,"pushed_at":"2022-07-18T05:55:26.000Z","size":123,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T16:57:58.785Z","etag":null,"topics":["go"],"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/berquerant.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":"2020-07-15T18:29:46.000Z","updated_at":"2022-07-18T05:55:29.000Z","dependencies_parsed_at":"2022-09-26T18:21:26.709Z","dependency_job_id":null,"html_url":"https://github.com/berquerant/circle","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fcircle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fcircle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fcircle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fcircle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berquerant","download_url":"https://codeload.github.com/berquerant/circle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246460299,"owners_count":20781084,"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":["go"],"created_at":"2024-12-13T13:14:22.591Z","updated_at":"2025-03-31T11:26:08.431Z","avatar_url":"https://github.com/berquerant.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## circle\n\ncircle provides sequences which support aggregation operations.\n\n[![GoDoc](https://godoc.org/github.com/berquerant/circle?status.svg)](https://godoc.org/github.com/berquerant/circle)\n\n### Example\n\n``` go\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/berquerant/circle\"\n)\n\n// tr -d ' ' | tr '[:upper:]' '[:lower:]' | grep -o . | sort | uniq -c | sort -rnk 1 | awk '{print $2, $1}'\nfunc main() {\n\tsc := bufio.NewScanner(os.Stdin)\n\t_ = circle.NewStreamBuilder(circle.MustNewIterator(func() (interface{}, error) {\n\t\tif sc.Scan() {\n\t\t\treturn sc.Text(), nil\n\t\t}\n\t\tif err := sc.Err(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, circle.ErrEOI\n\t})).\n\t\tFilter(func(x string) bool { return x != \"\" }).\n\t\tMap(func(x string) string { return strings.ReplaceAll(x, \" \", \"\") }).\n\t\tMap(strings.ToLower).\n\t\tMap(func(x string) []string { return strings.Split(x, \"\") }).\n\t\tFlat().\n\t\tAggregate(func(d map[string]int, x string) map[string]int {\n\t\t\td[x]++\n\t\t\treturn d\n\t\t}, map[string]int{}).\n\t\tFlat().\n\t\tSort(func(x, y circle.Tuple) bool { return x.MustGet(1).(int) \u003e y.MustGet(1).(int) }).\n\t\tTupleMap(func(x string, y int) string { return fmt.Sprintf(\"%s %d\", x, y) }).\n\t\tConsume(func(x string) { fmt.Println(x) })\n}\n```\n\n### Test\n\n``` shell\nmake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Fcircle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberquerant%2Fcircle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Fcircle/lists"}