{"id":17212444,"url":"https://github.com/jackfirth/point-free","last_synced_at":"2026-01-06T02:10:28.172Z","repository":{"id":25257521,"uuid":"28682642","full_name":"jackfirth/point-free","owner":"jackfirth","description":"Collection of forms and higher order functions that assist function composition and definition of functions in a point-free style","archived":false,"fork":false,"pushed_at":"2018-03-01T18:36:35.000Z","size":34,"stargazers_count":24,"open_issues_count":7,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T05:17:15.107Z","etag":null,"topics":["racket"],"latest_commit_sha":null,"homepage":null,"language":"Racket","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jackfirth.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":"2015-01-01T07:42:16.000Z","updated_at":"2022-06-11T16:55:23.000Z","dependencies_parsed_at":"2022-08-24T00:10:17.536Z","dependency_job_id":null,"html_url":"https://github.com/jackfirth/point-free","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Fpoint-free","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Fpoint-free/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Fpoint-free/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Fpoint-free/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackfirth","download_url":"https://codeload.github.com/jackfirth/point-free/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245466918,"owners_count":20620207,"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":["racket"],"created_at":"2024-10-15T03:00:04.398Z","updated_at":"2026-01-06T02:10:28.126Z","avatar_url":"https://github.com/jackfirth.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"point-free [![Build Status](https://travis-ci.org/jackfirth/point-free.svg?branch=master)](https://travis-ci.org/jackfirth/point-free) [![Coverage Status](https://coveralls.io/repos/jackfirth/point-free/badge.svg)](https://coveralls.io/r/jackfirth/point-free) [![Stories in Ready](https://badge.waffle.io/jackfirth/point-free.png?label=ready\u0026title=Ready)](https://waffle.io/jackfirth/point-free)\n==========\n\n[Documentation](http://pkg-build.racket-lang.org/doc/point-free/index.html)\n\nCollection of forms and higher order functions that assist function composition and definition of functions in a point-free style. Point-free functions are functions that don't name their arguments, they're created purely by composing other functions. For example:\n\n```racket\n(define number-\u003esymbol (compose string-\u003esymbol number-\u003estring))\n```\n\nRacket functions have symmetry between output and input values. This means that functions can accept multiple values and return multiple output values. This makes point-free functions more difficult to define, because regular function composition can be unwieldy. Contrast this to a language like Haskell, where functions can only accept and return one value.\n\nThere are two ways to compose two functions of one input and one output `f` and `g`. You can chain the output of `g` to the input of `f` with standard function composition, as in `(compose f g)`. However, you can also make a function that accepts two values, gives one to `f` and one to `g`, and returns both outputs as two values. Basically, functions can be composed in *series* or in *parallel*.\n\nThis package defines several convenient ways of composing functions to make point-free logic clean and simple to express. Composing functions in parallel can be done with the `join` function:\n\n```racket\n(define add1-sub1 (join add1 sub1))\n(add1-sub1 10 10) ;; evaluates to (values 11 9)\n```\n\nThe function `join*` takes a function and joins it with itself repeatedly\n\n```racket\n(define add1-each (join* add1))\n(add1-each 1 2 3) ;; evaluates to (values 2 3 4)\n```\n\nOn its own this function is rarely useful, but it can be combined elegantly with `compose`. Here's a point-free function that finds the hypotenuse of a right triangle (with `sqr` being a function that squares a number)\n\n```racket\n(define pythagoras (compose sqrt + (join* sqr)))\n(pythagoras 3 4) ;; evaluates to 5\n(pythagoras 5 12) ;; evaluates to 13\n```\n\nAnother included primitive composition function is `thrush`, which is the reverse of `compose` - the first function given to `thrush` gets inputs first, then gives its output to the second, which gives its output to the third, etc.:\n\n```racket\n(define symbol-length-even?\n  (thrush symbol-\u003estring\n          string-length\n          even?))\n(symbol-length-even? 'foo) ;; #f\n(symbol-length-even? 'barbaz) ;; #t\n```\n\nSome functions that combine these primitive composition operators together are included, including `wind*`, which takes three functions and essentially \"wraps\" the first function - all inputs to it are transformed with the second function, and all outputs from the first are transformed with the third:\n\n```racket\n(define pythagoras (wind* + sqr sqrt))\n(pythagoras 3 4) ;; evaluates to 5\n(pythagoras 5 12) ;; evaluates to 13\n```\n\nVariations on this function are also provided, as well as a more general `wind` function that can transform different inputs and outputs to the wound function with different transformer functions.\n\nA few macros for defining point-free functions with these composition operators are also included:\n\n```racket\n(define/compose first-even?\n  even? first)\n(define/thrush symbol-length-even?\n  symbol-\u003estring string-\u003enumber even?)\n(define/wind* pythagoras\n  + sqr sqrt)\n\n(first-even? '(2 3 4)) ;; #t\n(symbol-length-even? 'foo) ;; #f\n(pythagoras 3 4) ;; 5\n```\n\nThis package also supplies a way to compose functions that know how many arguments they have. The `arg-count` form takes an expression that produces a function and an identifier, and binds that identifier to contain the number of arguments given to the produced function in the expression:\n\n```racket\n(define num-args-received\n  (arg-count n (const n)))\n(num-args-received 'foo 'bar 'baz) ;; evaluates to 3\n```\n\nA definition form is also included:\n\n```racket\n(define/arg-count num-args-received n\n  (const n))\n```\n\nCombining this with syntax extensions for defining anonymous functions such as [`fancy-app`](https://github.com/samth/fancy-app) yields very succinct function definitions:\n\n```racket\n(define/arg-count average n\n  (compose (/ _ n) +))\n(average 8 10 12) ;; evaluates to 10\n```\n\nTo install, run `raco pkg install point-free`. Then to use in a module, `(require point-free)`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackfirth%2Fpoint-free","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackfirth%2Fpoint-free","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackfirth%2Fpoint-free/lists"}