All Projects → LoopPerfect → Conduit

LoopPerfect / Conduit

Licence: mit
High Performance Streams Based on Coroutine TS ⚡

Projects that are alternatives of or similar to Conduit

Projects
A list of awesome open source projects Vladimir Agafonkin is involved in.
Stars: ✭ 250 (+85.19%)
Mutual labels:  algorithms, performance
Arrow
Λrrow - Functional companion to Kotlin's Standard Library
Stars: ✭ 4,771 (+3434.07%)
Mutual labels:  functional-programming, coroutines
Taskr
A fast, concurrency-focused task automation tool.
Stars: ✭ 2,421 (+1693.33%)
Mutual labels:  coroutines, performance
Phunctional
⚡️ λ PHP functional library focused on simplicity and performance
Stars: ✭ 243 (+80%)
Mutual labels:  functional-programming, performance
Functionalplus
Functional Programming Library for C++. Write concise and readable C++ code.
Stars: ✭ 1,286 (+852.59%)
Mutual labels:  algorithms, functional-programming
Felix
The Felix Programming Language
Stars: ✭ 609 (+351.11%)
Mutual labels:  coroutines, functional-programming
Kotlinjetpackinaction
🔥🔥 Kotlin Jetpack zero to hero. 新手到高手
Stars: ✭ 264 (+95.56%)
Mutual labels:  coroutines, functional-programming
Functional Way
Write small programs (eg -algorithms) in a functional way.
Stars: ✭ 115 (-14.81%)
Mutual labels:  algorithms, functional-programming
Imtools
Fast and memory-efficient immutable collections and helper data structures
Stars: ✭ 85 (-37.04%)
Mutual labels:  functional-programming, performance
Splay Tree
Fast splay-tree data structure
Stars: ✭ 80 (-40.74%)
Mutual labels:  algorithms, performance
Haskell
Stars: ✭ 91 (-32.59%)
Mutual labels:  algorithms, functional-programming
Venice
Coroutines, structured concurrency and CSP for Swift on macOS and Linux.
Stars: ✭ 1,501 (+1011.85%)
Mutual labels:  coroutines, performance
Iter
Go implementation of C++ STL iterators and algorithms.
Stars: ✭ 132 (-2.22%)
Mutual labels:  algorithms
Zio Akka Cluster
ZIO wrapper for Akka Cluster
Stars: ✭ 134 (-0.74%)
Mutual labels:  functional-programming
Optics Ts
Type-safe, ergonomic, polymorphic optics for TypeScript
Stars: ✭ 132 (-2.22%)
Mutual labels:  functional-programming
Stagemonitor
an open source solution to application performance monitoring for java server applications
Stars: ✭ 1,664 (+1132.59%)
Mutual labels:  performance
Plasma
Plasma Programming Language
Stars: ✭ 133 (-1.48%)
Mutual labels:  functional-programming
Binance grid trader
A grid trading strategy and trading-bot for Binance Exchange. 币安交易所的网格交易
Stars: ✭ 132 (-2.22%)
Mutual labels:  algorithms
Splitties
A collection of hand-crafted extensions for your Kotlin projects.
Stars: ✭ 1,945 (+1340.74%)
Mutual labels:  coroutines
Gatling Dubbo
A gatling plugin for running load tests on Apache Dubbo(https://github.com/apache/incubator-dubbo) and other java ecosystem.
Stars: ✭ 131 (-2.96%)
Mutual labels:  performance

Conduit ⚡

Travis Godbolt

Lazy High Performance Streams using Coroutine TS

Conduit is a utility library for building and transforming, ranges and lazy (infinite) iterable sequences.

Conduit's goals are:

  • 🎨 Expressivity
  • 🎶 Composability
  • 🏃 Performance

These are attained by adopting a monadic interface that leverages zero-cost abstractions.

Install

Download the header-only library bundle from the releases page.

If you are using Buckaroo:

buckaroo add github.com/LoopPerfect/[email protected]=master

Build

To fetch dependencies (only required for testing and benchmarks):

buckaroo install

To build the library:

buck build :conduit

To run the examples:

buck run examples/primes
buck run examples/fibonacci
# etc...

To run the tests:

buck test //...

Examples

Use co_yield to define a coroutine and transform it using high-level operators.

using namespace std;
using namespace conduit;
using namespace conduit::operators;

auto fib = []() -> seq<int> {
  auto a = 0; 
  auto b = 1;
  while ( true ) {
    co_yield a;
    tie(a, b) = tuple{a + b, a};
  }
};

auto items = fib() 
  >> take(5)
  >> zipWith(range, [](auto x, auto y) { 
    return tuple{x, y};
  });

int vals[] = { 0, 1, 1, 2, 3, 5 };

for(auto [i, n] : items) {
  EXPECT_EQ(vals[i], n);
}

Construct elaborate algorithms using higher order operators:

#define RET(X) { return X; }

// sieve of eratosthenes
auto primes = [] {
  return range()
    >> map([](auto i) RET(3+i*2) ) // create a seqence of odd nums > 2
    >> flatMap([primes = vector<int>()](auto c) mutable RET ( 
      primes // divide each candidate by the primes we encountered
        >> find([c](auto p) RET (c % p == 0)) // search and stop if divisible
        >> count() // find yields at most 1 element, count how many we got (starts with zero)
        >> orElse(just(c)) // if we didn't find any, its a prime. yield it
        >> find([](auto x) RET (x)) // filter out zeros yielded by find+count or take prime
        >> forEach([&](auto p) {
          primes.push_back(p);  // update list of primes
        }) // Note: lifetime of primes-vector is bound to the coroutine  
    )) >> startsWith(just(2)); // two is the only even prime
};

Support

Currently only clang-7 with -fcoroutines-ts is supported.

MSVC support should be added in the near future.

Contributions Welcome!

Head over to our issue tracker to get involved in Conduit's development.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].