{"id":20228487,"url":"https://github.com/64j0/poc-cpp-functional","last_synced_at":"2025-10-16T10:23:27.066Z","repository":{"id":254027911,"uuid":"845204381","full_name":"64J0/poc-cpp-functional","owner":"64J0","description":"A POC showing how one can leverage C++ functional features to: partial application, higher order functions.","archived":false,"fork":false,"pushed_at":"2024-08-24T00:41:48.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-24T01:42:20.549Z","etag":null,"topics":["cpp","functional-programming"],"latest_commit_sha":null,"homepage":"","language":"C++","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/64J0.png","metadata":{"files":{"readme":"README.org","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":"2024-08-20T19:39:36.000Z","updated_at":"2024-08-24T00:41:51.000Z","dependencies_parsed_at":"2024-11-14T07:41:17.334Z","dependency_job_id":null,"html_url":"https://github.com/64J0/poc-cpp-functional","commit_stats":null,"previous_names":["64j0/poc-cpp-functional"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc-cpp-functional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc-cpp-functional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc-cpp-functional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc-cpp-functional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/64J0","download_url":"https://codeload.github.com/64J0/poc-cpp-functional/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241670158,"owners_count":20000327,"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":["cpp","functional-programming"],"created_at":"2024-11-14T07:30:44.224Z","updated_at":"2025-10-16T10:23:22.002Z","avatar_url":"https://github.com/64J0.png","language":"C++","readme":"#+TITLE: POC C++ partial application\n#+DATE: [2024-08-20 ter]\n\nThis repository holds a POC code showing how one can use partial applications in\nC++, along with a higher order function to compute the time it took to run\nanother functions.\n\nIt does implement the [[https://numpy.org/doc/stable/reference/generated/numpy.linspace.html][numpy.linespace]] function along with some helpers to print\nto the console the result and the time it took to run our linespace version.\n\n#+BEGIN_SRC bash\n  # I'm using g++ 11.4.0\n  g++ -O2 -o program.exe main.cpp\n\n  # Then execute\n  ./program.exe\n  # Sample result:\n  # ------------------------------------------------------------\n\n  # Time: 462ns\n  # array([0, 0, 0, 0, 0])\n\n  # Partial application with curied lambda functions\n  # Time: 259ns\n  # array([0, 0, 0, 0, 0])\n\n  # Partial application with std::bind\n  # Time: 329ns\n  # array([0, 0, 0, 0, 0])\n  # ------------------------------------------------------------\n\n  # Time: 173ns\n  # array([0, 2, 4, 6])\n\n  # Partial application with curied lambda functions\n  # Time: 130ns\n  # array([0, 2, 4, 6])\n\n  # Partial application with std::bind\n  # Time: 136ns\n  # array([0, 2, 4, 6])\n  # ------------------------------------------------------------\n\n  # Time: 108ns\n  # array([0, 1.5, 3, 4.5])\n\n  # Partial application with curied lambda functions\n  # Time: 139ns\n  # array([0, 1.5, 3, 4.5])\n\n  # Partial application with std::bind\n  # Time: 166ns\n  # array([0, 1.5, 3, 4.5])\n  # ------------------------------------------------------------\n\n  # Time: 245ns\n  # array([0, 0.444444, 0.888889, 1.33333, 1.77778, 2.22222, 2.66667, 3.11111, 3.55556, 4])\n\n  # Partial application with curied lambda functions\n  # Time: 224ns\n  # array([0, 0.444444, 0.888889, 1.33333, 1.77778, 2.22222, 2.66667, 3.11111, 3.55556, 4])\n\n  # Partial application with std::bind\n  # Time: 265ns\n  # array([0, 0.444444, 0.888889, 1.33333, 1.77778, 2.22222, 2.66667, 3.11111, 3.55556, 4])\n  # ------------------------------------------------------------\n\n  # Time: 192ns\n  # array([0, 0.4, 0.8, 1.2, 1.6, 2, 2.4, 2.8, 3.2, 3.6])\n\n  # Partial application with curied lambda functions\n  # Time: 168ns\n  # array([0, 0.4, 0.8, 1.2, 1.6, 2, 2.4, 2.8, 3.2, 3.6])\n\n  # Partial application with std::bind\n  # Time: 212ns\n  # array([0, 0.4, 0.8, 1.2, 1.6, 2, 2.4, 2.8, 3.2, 3.6])\n  # ------------------------------------------------------------\n\n  # Time: 140ns\n  # array([2, 2.2, 2.4, 2.6, 2.8])\n\n  # Partial application with curied lambda functions\n  # Time: 127ns\n  # array([2, 2.2, 2.4, 2.6, 2.8])\n\n  # Partial application with std::bind\n  # Time: 175ns\n  # array([2, 2.2, 2.4, 2.6, 2.8])\n  # ------------------------------------------------------------\n\n  # Time: 131ns\n  # array([2, 2.25, 2.5, 2.75, 3])\n\n  # Partial application with curied lambda functions\n  # Time: 130ns\n  # array([2, 2.25, 2.5, 2.75, 3])\n\n  # Partial application with std::bind\n  # Time: 168ns\n  # array([2, 2.25, 2.5, 2.75, 3])\n  # ------------------------------------------------------------\n\n  # Time: 149ns\n  # array([3, 2.75, 2.5, 2.25, 2])\n\n  # Partial application with curied lambda functions\n  # Time: 132ns\n  # array([3, 2.75, 2.5, 2.25, 2])\n\n  # Partial application with std::bind\n  # Time: 166ns\n  # array([3, 2.75, 2.5, 2.25, 2])\n#+END_SRC\n\nSome useful links:\n\n- https://habr.com/en/articles/436488/\n- https://en.cppreference.com/w/cpp/utility/functional/bind\n- https://learn.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp?view=msvc-170#capture-clause\n\n** Using nix\n\nInspired by [[https://nixcademy.com/posts/cpp-with-nix-in-2023-part-1-shell/][link]].\n\n#+BEGIN_SRC bash\n  nix develop\n#+END_SRC\n\n*It does not work properly with C++ 23. For example, I can't use the [[https://en.cppreference.com/w/cpp/header/print][print]]\n library header.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64j0%2Fpoc-cpp-functional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F64j0%2Fpoc-cpp-functional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64j0%2Fpoc-cpp-functional/lists"}