bisect 1.0.2 copy "bisect: ^1.0.2" to clipboard
bisect: ^1.0.2 copied to clipboard

A library that implements a simple bisection algorithm for insertion in sorted lists.

example/bisect_example.dart

import 'package:bisect/bisect.dart';

void main() {
  /// Get the letter grade of a test based on it's numerical
  /// marks, using the bisect function for numerical lookup
  String grade(num score, {List<num> breakpoints = const [50, 68, 79, 90], grades = 'FDCBA'}){
    var index = breakpoints.bisect(score);
    return grades[index];
  }

  print(grade(87)); // B
}
4
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A library that implements a simple bisection algorithm for insertion in sorted lists.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on bisect