GithubHelp home page GithubHelp logo

range's Introduction

range

This module offers functionality similar to Python.

There are 4 functions that create iterators with lazy evaluation:

  • int_iter: similar to Python's range() for integer numbers
  • float_iter: similar to Numpy's arange for floats
  • lin_iter: similar to Numpy's linspace
  • log_iter: similar to Numpy's logspace

The main defference with the Numpy functions is that the functions in this module return iterators rather than arrays, but can be used to create arrays.

All the iterators have a len attribute.

Exemples

int_iter

for i in int_iter(stop:5) {
	println(i)
}
0
1
2
3
4

for i in int_iter(start:3, stop:23, step:4) {
	println(i)
}
3
7
11
15
19

for i in int_iter(start:5, stop:-10, step:-3) {
	println(i)
}
5
2
-1
-4
-7

float_iter

for i in float_iter(start:1, stop:3, step:0.5) {
	println(i)
}
1.
1.5
2.
2.5

for i in float_iter(stop:-1, step: -0.25) {
	println(i)
}
0
-0.25
-0.5
-0.75

lin_iter

for i in lin_iter(start: 0.5, stop: 1.25, len:5) {
	println(i)
}
0.5
0.6875
0.875
1.0625
1.25

for i in lin_iter(start: 0.5, stop: 1.25, len:5, endpoint: false) {
	println(i)
}
0.5
0.65
0.8
0.95
1.1

log_iter

for i in log_iter(start: 0, stop: 3, len:5){
	println(i)
}
1.
5.623413251903491
31.622776601683796
177.8279410038923
1000

for i in log_iter(start: 0, stop: 3, len:5, base:2){
	println(i)
}
1.
1.681792830507429
2.82842712474619
4.756828460010884
8.

.len

r := int_iter(stop:25, step:4)
println('len: $r.len')
len: 7

range's People

Contributors

arielthenon avatar

Watchers

 avatar

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.