{"id":37201002,"url":"https://github.com/johncgriffin/yogofn","last_synced_at":"2026-01-14T23:10:38.592Z","repository":{"id":57491060,"uuid":"92683563","full_name":"JohnCGriffin/yogofn","owner":"JohnCGriffin","description":"Functional Map/Reduce/Filter for Golang","archived":false,"fork":false,"pushed_at":"2017-06-13T21:23:52.000Z","size":22,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-14T00:24:09.847Z","etag":null,"topics":["functional-programming","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JohnCGriffin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-28T19:52:36.000Z","updated_at":"2024-04-10T20:02:14.000Z","dependencies_parsed_at":"2022-08-30T04:00:11.003Z","dependency_job_id":null,"html_url":"https://github.com/JohnCGriffin/yogofn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JohnCGriffin/yogofn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnCGriffin%2Fyogofn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnCGriffin%2Fyogofn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnCGriffin%2Fyogofn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnCGriffin%2Fyogofn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JohnCGriffin","download_url":"https://codeload.github.com/JohnCGriffin/yogofn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnCGriffin%2Fyogofn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28437933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"last_error":"SSL_read: 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":["functional-programming","golang"],"created_at":"2026-01-14T23:10:37.771Z","updated_at":"2026-01-14T23:10:38.556Z","avatar_url":"https://github.com/JohnCGriffin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yogofn\nFunctional Map/Reduce/Filter for Golang\n\n### install\ngo get github.com/johncgriffin/yogofn\n\nYogofn offers a few slice generating operations as alternatives to Go's for-loops.\n\nFor instance, let's find the max daily temperature range given two parallel lists of low and high daily temperatures.\nHere's standard Go code given two float64 slices.\n\n```\nvar maxDailyRange float64\nfor i:=0; i\u003clen(highs) \u0026\u0026 i\u003clen(lows); i++ {\n    maxDailyRange = math.Max(highs[i] - lows[i], maxDailyRange)\n}\n```\nAnd here's using yogofn:\n```\nmaxDailyRange := Reduce(MaxF64, Map(SubF64, highs, lows)).(float64)\n```\n\nNotice that the final outside operation (Reduce in this instance) required a cast to inform Go of the final type.  Inputs are either arrays or slices of any type.  Yogofn offers:\n\n- ``Map(f,slice(s))`` -\u003e slice projection\n- ``Filter(f,slice)`` -\u003e slice selection\n- ``Reduce(f,slice(s))`` -\u003e scalar\n- ``Every(f,slice)`` -\u003e bool \n- ``Any(f,slice)`` -\u003e bool\n\nNotice that because Reduce and Map can take more than one list, Zip is effected via\n\n```\nzipped := Map(func(x,y string) []string { return []string{x,y} }, xs, ys).([][]string)\n```\nA companion package is yogofn/reducers which contains simple but common scalar reductions for int and float64 numbers.\n\n#### Reflection Performance\n\nNot suprisingly, reflection slows down standard Go about 200 times.  Using Go's type switch, a few optimizations \nwere placed into Map/Filter/Reduce \nfor common data types float64, int, and string.  Those operations are implemented as normal typed Go loops.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohncgriffin%2Fyogofn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohncgriffin%2Fyogofn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohncgriffin%2Fyogofn/lists"}