tailcalls 0.0.1

  • README.md
  • Changelog.md
  • Installing
  • Versions
  • 48

tailcall

A library for trampolining tail calls.

Example 1:

import 'package:tailcalls/tailcalls.dart';

TailRec<int> fib(int n) {
  if (n < 2) {
    return done(n);
  } else {
    return tailcall(() => fib(n - 1)).flatMap((x) {
      return tailcall(() => fib(n - 2)).map((y) {
        return (x + y);
      });
    });
  }
}

void main() {
  var res = fib(20).result();
  print("Result: $res");
}

Example 2:

TailRec<bool> isEven(List<int> xs) {
  if (xs.isEmpty) {
    return done(true);
  } else {
    return tailcall(() => isOdd(xs.sublist(1)));
  }
}

TailRec<bool> isOdd(List<int> xs) {
  if (xs.isEmpty) {
    return done(false);
  } else {
    return tailcall(() => isEven(xs.sublist(1)));
  }
}

void main() {
  List<int> r = rangeList(1, 40002);
  print(r.last);
  bool res = isEven(r).result();
  print(res);
}

Read more about trampoling in computing on Wikipedia.

Changelog

0.0.1

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  tailcalls: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:tailcalls/tailcalls.dart';
  
Version Uploaded Documentation Archive
0.0.1 Dec 14, 2017 Go to the documentation of tailcalls 0.0.1 Download tailcalls 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:tailcalls/tailcalls.dart.

Issues and suggestions

Homepage does not exists.

We were unable to access https://plus.google.com/+Welopment at the time of the analysis.

The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Maintain an example.

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use tailcalls.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <=2.0.0