{"id":19865955,"url":"https://github.com/kamstrup/fn","last_synced_at":"2026-01-12T14:06:27.793Z","repository":{"id":64147824,"uuid":"569757839","full_name":"kamstrup/fn","owner":"kamstrup","description":"Functional programming in Go","archived":false,"fork":false,"pushed_at":"2024-02-12T12:23:55.000Z","size":249,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-12T15:31:40.455Z","etag":null,"topics":["functional-programming","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamstrup.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-11-23T14:47:03.000Z","updated_at":"2024-11-08T06:03:22.000Z","dependencies_parsed_at":"2024-02-12T13:47:55.118Z","dependency_job_id":null,"html_url":"https://github.com/kamstrup/fn","commit_stats":{"total_commits":156,"total_committers":1,"mean_commits":156.0,"dds":0.0,"last_synced_commit":"63311e291b462e60f6eed46012e50569e1a2f8d2"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamstrup%2Ffn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamstrup%2Ffn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamstrup%2Ffn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamstrup%2Ffn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamstrup","download_url":"https://codeload.github.com/kamstrup/fn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251992993,"owners_count":21677022,"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":["functional-programming","golang"],"created_at":"2024-11-12T15:24:38.105Z","updated_at":"2026-01-12T14:06:27.773Z","avatar_url":"https://github.com/kamstrup.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Fn(), Functional Programming for Golang\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/kamstrup/fn)](https://goreportcard.com/report/github.com/kamstrup/fn) [![PkgGoDev](https://pkg.go.dev/badge/github.com/kamstrup/fn)](https://pkg.go.dev/github.com/kamstrup/fn)\n\nFn is library for golang that enable you to blend functional programming techniques\nwith standard idiomatic Go code.\n\nWe are inspired by [Clojure](https://github.com/clojure/clojure),\n[Vavr](https://github.com/vavr-io/vavr), and the Java Streams APIs that were\nintroduced back in Java 8, and want to provide something of similar spirit\nthat makes it even more fun to write Go code.\n\n## Documentation\nYou will find [comprehensive documentation in our docs folder](doc), or you might want to dive\ndirectly into our [simple examples](https://github.com/kamstrup/fn/blob/main/examples/simple_test.go).\n\n## Examples\n```go\nimport (\n    \"fmt\"\n\t\n    \"github.com/kamstrup/fn/seq\"\n)\n\nfunc printGreenTeam() {\n    blueTeam := seq.SliceOfArgs(\"Alan\", \"Betty\")\n    redTeam := seq.SliceOfArgs(\"Maria\", \"Bob\")\n    \n    // Let's create a set of names for the people on the blue and red teams\n    allTeamMembers := seq.ConcatOf(blueTeam, redTeam)\n    nameSet := seq.Reduce(seq.MakeSet[string], nil, allTeamMembers).Or(nil)\n    \n    // We need 2 members for the green team, that are not already on the blue or red team\n    greenTeam := seq.SliceOfArgs(\"Betty\", \"Maurice\", \"Bob\", \"Charles\", \"Inga\").\n        Where(seq.Not(nameSet.Contains)).\n        Limit(2).\n        ToSlice()\n    \n    if len(greenTeam) != 2 {\n        panic(\"not enough team members for the green team\")\n    }\n    \n    // Members on the green team are assigned player numbers starting from 10\n    greenTeamNumbers := seq.ZipOf[int, string](seq.RangeFrom(10), greenTeam)\n    greenTeamNumbers.ForEach(func (member seq.Tuple[int, string]) {\n        fmt.Println(\"Name:\", member.Value(), \"Number:\", member.Key())\n    })\n    // Prints:\n    // Name: Maurice Number: 10\n    // Name: Charles Number: 11\n}\n```\n\n## Performance\nIf the foundational functional data structures and algorithms is not done carefully,\nexecution speed and memory usage will suffer. Fn() is designed to make the best of what\nthe Go runtime can provide. Initial benchmarks puts it as a top contender among Golang\nfunctional libraries. See benchmarks here https://github.com/mariomac/go-stream-benchmarks/pull/1\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamstrup%2Ffn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamstrup%2Ffn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamstrup%2Ffn/lists"}