Giter Site home page Giter Site logo

set's Introduction

Set

Build status

This is a Swift microframework which implements a PredicateSet and a Dictionary-backed Multiset.

Use

Multiset:

// Union
Multiset(1, 2, 3) + Multiset(3, 4, 5) // == Multiset(1, 2, 3, 3, 4, 5)

// Difference
Multiset(1, 2, 3) - Multiset(2, 3) // == Multiset(1)

// Intersection
Multiset(1, 2, 3) & Multiset(3, 4, 5) // == Multiset(3)

PredicateSet:

// Union
let union = PredicateSet { $0 > 0 } + PredicateSet { $0 % 2 == 0 }
union.contains(3) // true

// Difference
let difference = PredicateSet { $0 > 0 } - PredicateSet { $0 % 2 == 0 }
difference.contains(6) // false

// Special Sets
func isInt(number: Float) -> Bool {
	return Float(Int(number)) == number
}

let Q: PredicateSet<Float> = PredicateSet { _ in true } // Set of all real numbers.
let Z = Q & PredicateSet { isInt($0) } // Set of all integers.
let N = Z & PredicateSet { $0 > 0 } // Set of all natural numbers.

N.contains(1) // true
N.contains(-1.5) // false

See Multiset.swift and PredicateSet.swift for more details.

Integration

  1. Add this repo as a submodule in e.g. External/Set:

     git submodule add https://github.com/robrix/Set.git External/Set
    
  2. Drag Set.xcodeproj into your .xcworkspace/.xcodeproj.

  3. Add Set.framework to your target’s Link Binary With Libraries build phase.

  4. You may also want to add a Copy Files phase which copies Set.framework (and any other framework dependencies you need) into your bundle’s Frameworks directory. If your target is a framework, you may instead want the client app to include Set.framework.

Thanks

set's People

Contributors

a2 avatar alexrozanski avatar amackworth avatar ingmarstein avatar m4tbat avatar natecook1000 avatar robb avatar robrix avatar sharplet avatar

Watchers

 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.