{"id":22646261,"url":"https://github.com/armcn/fp","last_synced_at":"2025-09-11T05:41:50.651Z","repository":{"id":138372820,"uuid":"453535075","full_name":"armcn/fp","owner":"armcn","description":"Almost Practical Functional Programming in R","archived":false,"fork":false,"pushed_at":"2022-02-01T00:53:01.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T06:30:22.459Z","etag":null,"topics":["functional-programming","r","rstats"],"latest_commit_sha":null,"homepage":"","language":"R","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/armcn.png","metadata":{"files":{"readme":"README.Rmd","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-29T22:36:30.000Z","updated_at":"2022-01-29T22:52:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"28e62ad7-7f75-4181-b2d9-bb6c71601267","html_url":"https://github.com/armcn/fp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/armcn/fp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armcn%2Ffp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armcn%2Ffp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armcn%2Ffp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armcn%2Ffp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/armcn","download_url":"https://codeload.github.com/armcn/fp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armcn%2Ffp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274583981,"owners_count":25311901,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","r","rstats"],"created_at":"2024-12-09T06:09:22.540Z","updated_at":"2025-09-11T05:41:50.641Z","avatar_url":"https://github.com/armcn.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# fp\n\n# Overview\n\nFunctional programming in R.\n\n## Installation\n\nYou can install the development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"armcn/fp\")\n```\n\n## Usage\n\n### Vector functions\n\n```{r}\nlibrary(fp, warn.conflicts = FALSE)\n\nnumbers \u003c- 1:10\nnumbers_list \u003c- as.list(numbers)\n\nmap(\\(a) a + 1, numbers)\n\nmap2(`+`, numbers, numbers)\n\nfilter(\\(a) a \u003e 5, numbers)\n\nreduce(`+`, 0, numbers)\n\nscan(`*`, 1, numbers)\n\nany(\\(a) a %% 2 == 0, numbers)\n\nall(\\(a) a %% 2 == 0, numbers)\n\nmember(5, numbers)\n\nfirst(numbers_list)\n\nlast(numbers_list)\n\nhead(numbers_list)\n\ntail(numbers)\n\ninit(numbers)\n\nget_at(3, numbers_list)\n```\n\n### Function composition\n\n```{r}\nsquare \u003c- \\(a) a ^ 2\nis_even \u003c- \\(a) a %% 2 == 0\n\nnumbers |\u003e \n  map(square)() |\u003e\n  filter(is_even)() |\u003e\n  reduce(`+`, 0)()\n\nnumbers %|\u003e% \n  map(square) %|\u003e% \n  filter(is_even) %|\u003e% \n  reduce(`+`, 0)\n\npipe(\n  map(square), \n  filter(is_even), \n  reduce(`+`, 0)\n)(numbers)\n\ncompose(\n  reduce(`+`, 0),\n  filter(is_even),\n  map(square)\n)(numbers)\n\nsum_even_squares \u003c- \n  reduce(`+`, 0) %.% \n  filter(is_even) %.%\n  map(square)\n\nsum_even_squares(numbers)\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmcn%2Ffp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmcn%2Ffp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmcn%2Ffp/lists"}