Coder Social home page Coder Social logo

flurine_lambda's Introduction

A library for Dart developers.

Created from templates made available by Stagehand under a BSD-style license.

Usage

A simple usage example:

import 'package:lambda/flurine_lambda.dart';

const TIME = 'tm';
const CONCAT = 'cc';

void main() async {
  Handler.registerMany({
    CONST: () => ConstHandler(),
    TIME: () => TimeHandler(),
    CONCAT: () => ConcatHandler(),
  });
  await Vein.init();
  final lambda = Lambda.parse('\$tm(2)\$');
  await lambda.execute();
  lambda.vein.listen(onData);
}

void onData(data) {
  print(data);
}

In above formula :

- 'tm' is Lambda keyword,
- 2 (integer) is argument which is handled by [TimeHandler] 
- whole lambda should be wrapped between $ sign.
- handlers should be registerd first.

Here whole data is processed behind single Isolate (here [Vein]) which should be initialized first.

I don't where you can use this library or an idea like this but here it is.

class TimeHandler extends Handler {

  @override
  Future compute() async {
    return DateTime.now().second;
  }

  @override
  Duration get repeatingDuration => Duration(seconds:params.last);
}

class CounterHandler extends Handler {

  @override
  Duration get repeatingDuration => null;

  int begin, end, step,current;

  @override
  set params(List params) {
    this.params = params;
    begin = params[0];
    end = params[1];
    step = params[2];
    current = params[3];
  }

  @override
  Future compute() async {
    if (current == null || current > end) current = begin;
    int temp = current;
    current = current + step;
    return temp;
  }
}

class ConcatHandler extends Handler{

  @override
  Duration get repeatingDuration => null;

  @override
  Future compute() async{
    return params.join();
  }

}

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.