Git Product home page Git Product logo

pretzel's Introduction

pretzel

General predicate functions. Combine predicates into new ones, plus a bunch of predicates on strings.

Usage

Get the code from clojars: http://clojars.org/pretzel

(require '[pretzel.strings :as str])

(str/natural? "1234")
(str/integer? "-123213")             
(str/hex? "deadb33f")
((str/length 3) "bla")
((str/length 2 4) "bla")
(str/web-url? "http://foo.bar/somewhere")

(str/looks-like-email? "[email protected]")
(str/looks-like-phone? "+ (020) 213213-2323")

(use 'pretzel.combine)

((every-p?
  str/natural?
  (str/length 2 3))
 "123")

API

strings

Functions in pretzel.strings all operate on strings. Functions with names ending in "?" should be real predicates - that is; they return strictly true or false. Predicates that require additional parameters are generated as curried functions. See pretzel.string/length for an example.

Functions that are named looks-like-* are approximations and may yield false positives and false negatives. The strategy is to minimize overall false negatives in the "real world". There are currently no equivalent functions to minimize false positives.

combining predicates

Functions in pretzel.combine combine multiple predicates applying to the same argument(s) into a new predicate. Currently, the combinations are based on the clojure.core combinations some, every?, not-any? and not-every?. Note that, since some isn't a predicate, some-p is not a strict predicate either.

Open development

Any additional predicates are welcomed, as are bug fixes or reports. For bug fixes/reports, keep in mind that looks-like-* predicates are meant to be roughly non-strict. If you've got suggestions for strict counter-parts, please also suggest a naming scheme and implementations.

The quickest way to get fixes & features in this project is to open a pull request for a patch. See the github documentation on pull requests on how to go about that.

License

Copyright (C) 2011 Joost Diepenmaat, Zeekat Softwareontwikkeling [email protected] - http://joost.zeekat.nl/

Distributed under the Eclipse Public License, the same as Clojure.

pretzel's People

Contributors

joodie avatar

Stargazers

Max Weber avatar

Watchers

Max Weber avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.