{"id":17212442,"url":"https://github.com/jackfirth/predicates","last_synced_at":"2026-01-05T23:02:56.027Z","repository":{"id":23616745,"uuid":"26986107","full_name":"jackfirth/predicates","owner":"jackfirth","description":"Deprecated. A racket package for creating predicates in a point-free style.","archived":false,"fork":false,"pushed_at":"2021-11-16T23:07:12.000Z","size":31,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T05:17:15.121Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Racket","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/jackfirth.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":"2014-11-22T02:25:52.000Z","updated_at":"2023-12-17T17:22:47.000Z","dependencies_parsed_at":"2022-08-22T02:11:00.880Z","dependency_job_id":null,"html_url":"https://github.com/jackfirth/predicates","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%2Fpredicates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Fpredicates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Fpredicates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Fpredicates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackfirth","download_url":"https://codeload.github.com/jackfirth/predicates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245466933,"owners_count":20620208,"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":[],"created_at":"2024-10-15T03:00:04.168Z","updated_at":"2026-01-05T23:02:55.978Z","avatar_url":"https://github.com/jackfirth.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"predicates [![Build Status](https://travis-ci.org/jackfirth/predicates.svg?branch=master)](https://travis-ci.org/jackfirth/predicates) [![Coverage Status](https://coveralls.io/repos/jackfirth/predicates/badge.svg?branch=master)](https://coveralls.io/r/jackfirth/predicates?branch=master)\n==========\n\n[Documentation](http://pkg-build.racket-lang.org/doc/predicates/index.html)\n\n**Deprecated** - For basic logic combinators, use `conjoin`, `disjoin`, and `negate` from `racket/function` instead. For predicate-constructing variants of `eq?` and friends, use a simple lambda shorthand library like `fancy-app` instead. For the more complex combinators, consider them unmaintained.\n\nA racket package for creating predicates in a point-free style.\n\nA *predicate* is a function that takes one argument and returns either true or false. You can think of it as a question, such as `even?` which returns true for even numbers and false for odd numbers. This package provides several tools for working with predicates.\n\nPredicates can be combined logically\n\n```racket\n(filter (or? symbol? string?) '(1 a 3 \"blah\" b 4 5))\n; -\u003e '(a \"blah\" b)\n\n(filter (and? number? even?) '(a b 2 5 6 \"foo\" bar 9 8))\n; -\u003e '(2 6 8)\n\n(filter (not? symbol?) '(a b 2 3 \"baz\" d))\n; -\u003e '(2 3 \"baz\")\n```\n\nPredicates can be created to compare things\n\n```racket\n(filter (\u003c? 5) '(3 4 5 6 7))\n; -\u003e '(3 4)\n(filter (eq?? 'foo) '(foo bar baz))\n; -\u003e '(foo)\n(define digit? (and? exact-positive-integer? (\u003c? 10)))\n(filter digit? '(a b 2 5 c \"foo\" 12 15 8))\n; -\u003e '(2 5 8)\n```\n\nPredicates can be created and combined to query lists\n\n```racket\n(nonempty-list? '(a b c)) ; -\u003e #t\n(nonempty-list? '()) ; -\u003e #f\n(nonsingular-list? '(a b c)) ; -\u003e #t\n(nonsingular-list? '(a)) ; -\u003e #f\n\n(define second-number? (second? number?))\n(second-number? '(1 2 3)) ; -\u003e #t\n(second-number? '(1 a 3)) ; -\u003e #f\n\n(define three-nums? (listof? number? number? number?))\n(three-nums? '(1 2 3)) ; -\u003e #t\n(three-nums? '(1 2 3 4)) ; -\u003e #f\n(three-nums? '(a b 2)) ; -\u003e #f\n\n(define starts-with-sym-str? (list-with-head? symbol? string?))\n(starts-with-sym-str? '(a \"foo\" 1 2 3)) ; -\u003e #t\n(starts-with-sym-str? '(a 1 2 3)) ; -\u003e #f\n\n((length\u003e? 2) '(a b c)) ; -\u003e #t\n((length\u003e? 2) '(a)) ; -\u003e #f\n```\n\nOnce you've got all these fancy predicates, you can use them to add conditional logic to functions.\n\n```racket\n(define (halve x) (/ x 2))\n(define (triple-add1 x) (add1 (* x 3)))\n(define collatz (if? even? halve triple-add1))\n(collatz 4) ; -\u003e 2\n(collatz 5) ; -\u003e 16\n(collatz 7) ; -\u003e 22\n(collatz 1) ; -\u003e 4\n```\n\nOr use them as loop conditions in higher-order loop construction functions.\n\n```racket\n(define last (compose first (while? nonsingular-list? rest)))\n(last '(1 2 3 4 5))\n(define (last? p) (compose p last))\n((last? even?) '(1 2 3 4 5))   ; -\u003e #f\n((last? even?) '(1 2 3 4 5 6)) ; -\u003e #t\n```\n\nTo install, run `raco pkg install predicates`. Then to use in a module, `(require predicates)`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackfirth%2Fpredicates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackfirth%2Fpredicates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackfirth%2Fpredicates/lists"}