Skip to content

Lazy and efficient 'range' iterables to generate values based on start, stop and step/count.

License

Notifications You must be signed in to change notification settings

Grizzly-dart/range

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Range

Lazy and efficient 'range' iterables to generate values based on start, stop and step/count.

for (final i in 0.to(5)) {
  print(i);
}

Range a length from [0, n) with step 1:

// int n = 10; // Some length n
for (final i in n.range) {
  print(i);
}
// int n = 10; // Some length n
for (final i in n.take(10)) {
  print(i);
}

Ranges can also be descending:

for (final i in 5.to(-5)) {
  print(i);
}

Linspace

IntRange.linspace returns an Iterable<int> with range [start, stop] with [count] elements in it.

print(1.linspace(10, 5));

Time ranges

print(TimeRange(
      DateTime(2019, 1, 1), DateTime(2019, 1, 20), Duration(days: 1)));

Month range

print(MonthRange(DateTime(2020, 2, 29), DateTime(2032, 2, 30), 6));

ticks

print(ticks(-100, 1000000, 10));
// => [-100000, 0, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]

Extent

Extent of list

print(List.generate(11, (i) => i * 10).findExtent()); // => Extent(0, 100)

Ranging an Extent

print(Extent(5, 50).range(5));

Generate random numbers

print(Extent(5, 50).rands(100));

Extents

Bin

  final extents = List.generate(11, (i) => i * 10).edgesToExtents();
  final data = extents.rands(20)!;
  print(extents.computeBins(data));

Counts

  final extents = List.generate(11, (i) => i * 10).edgesToExtents();
  final data = extents.rands(20)!;
  print(extents.computeCounts(data));

Histogram

  final extents = List.generate(11, (i) => i * 10).edgesToExtents();
  final data = extents.rands(20)!;
  print(extents.computeHistogram(data));

About

Lazy and efficient 'range' iterables to generate values based on start, stop and step/count.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages