Giter Club home page Giter Club logo

iter8's Introduction

iter8

Iter8 is a small Lua library which provides an iterator object. The interface is heavily inspired by Rust's iterators.

Example

local Iter8 = require "iter8"

for c, n in Iter8.chars("hello"):zip(Iter8.range(5)) do
    print(c .. " is letter number " .. tostring(n))
end

-- Print the primes up to 100
Iter8.range(100):filter(isPrime):foreach(print)

Installation

TODO

Semver

TODO

Documentation

TODO

Contributing

TODO

Running the test suite

TODO

Building the documentation

TODO

iter8's People

Contributors

jparoz avatar

Watchers

 avatar

iter8's Issues

Support for `nil` as an iterator value (i.e. support for sparse tables)

Some Lua functions are capable of handling nil arguments nicely:

  • Lua 5.4's table.pack adds a field n to the resulting table, such that the consumer can detect nil values.
  • select("#", ...) can detect nil arguments being passed.

It's unclear if there's any way to make Iter8 support nil values in this way. Currently, any time an iterator yields nil, the iterator will finish then and there.

If you are reading this, and have a use case for nil values in iterators, feel free to comment what your use case is, and how you'd prefer the semantics to work. If it's possible to implement this in a backwards-compatible way, I would try to do so.

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.