GithubHelp home page GithubHelp logo

apophany's Introduction

apophany

a pattern matcher that matches sequences of things in a filtered list

What is it?

Apophany is a pattern matcher that uses an optionally filtered list, and a sequence of matching functions to match a pattern in a list of things.

Suppose you have a list like this:

[1, 2, 'three', 'four', 5, 6]

And you wanted to match the pattern of a number followed by a string, you could write two functions like this and put them in a list:

[
  item => typeof item === 'number',
  item => typeof item === 'string'
]

In this case, the pattern would match 2, 'three', and the object returned by the function would include information about these items in the array

What does ‘apophany’ mean?

An apophany is the name given to the moment when you recognize a pattern in something that isn't really there. It's the opposite of an epiphany, which is the name given to the moment when you finally recognize a pattern that has been there the whole time.

Usage

apophany(list, patterns, filter)
  • list is an array of items to be matched
  • patterns is an array containing functions to test each sequential token in the pattern
  • filter is an optional function to be used with Array.filter() of the list

Examples

apophany's People

Contributors

tomhodgins avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  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.