GithubHelp home page GithubHelp logo

tchigher / swift-algorithms Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apple/swift-algorithms

0.0 0.0 0.0 75 KB

Swift Algorithms is an open-source package of sequence and collection algorithms, along with their related types.

License: Apache License 2.0

Swift 100.00%

swift-algorithms's Introduction

Swift Algorithms

Swift Algorithms is an open-source package of sequence and collection algorithms, along with their related types.

Read more about the package, and the intent behind it, in the announcement on swift.org.

Contents

Combinations / permutations

Mutating algorithms

Combining collections

  • chained(with:): Concatenates two collections with the same element type.
  • product(_:_:): Iterates over all the pairs of two collections; equivalent to nested for-in loops.
  • cycled(), cycled(times:): Repeats the elements of a collection forever or a set number of times.

Subsetting operations

Other useful operations

  • chunked(by:), chunked(on:): Eager and lazy operations that break a collection into chunks based on either a binary predicate or when the result of a projection changes.
  • indexed(): Iterate over tuples of a collection's indices and elements.

Adding Swift Algorithms as a Dependency

To use the Algorithms library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:

.package(url: "https://github.com/apple/swift-algorithms", from: "0.0.1"),

Because Algorithms is under active development, source-stability is only guaranteed within minor versions (e.g. between 0.0.3 and 0.0.4). If you don't want potentially source-breaking package updates, use this dependency specification instead:

.package(url: "https://github.com/apple/swift-algorithms", .upToNextMinor(from: "0.0.1")),

Finally, include "Algorithms" as a dependency for your executable target:

let package = Package(
    // name, platforms, products, etc.
    dependencies: [
        .package(url: "https://github.com/apple/swift-algorithms", from: "0.0.1"),
        // other dependencies
    ],
    targets: [
        .target(name: "<target>", dependencies: [
            .product(name: "Algorithms", package: "swift-algorithms"),
        ]),
        // other targets
    ]
)

swift-algorithms's People

Contributors

natecook1000 avatar kylemacomber avatar nordicio avatar austinconlon avatar iankeen avatar karwa avatar schlagelk 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.