Morpho-lang / morpho

The Morpho language 🦋. Morpho is a small embeddable language for scientific computing applications.
MIT License
33 stars 11 forks source link

[Feature Request] Range arithmetic #116

Open joshichaitanya3 opened 2 years ago

joshichaitanya3 commented 2 years ago

As the recent issues point out, the Ranges are tricky with floats as spacing. It'd be nice to be able to do arithmetic on Ranges, so that we can have Ranges generated from integers and multiplied by the required spacing later on. Something like this

// Go from 0 to 1 in N+1 steps
var N = 10
var range = 0..N // I think this is always exact?
range = range/N // This operation, if possible, would give a Range going from 0 to 1 exactly in N+1 steps, without worrying about floating point.

Alternatively or additionally, we could have a different kind of Range object going from a to b in a fixed number of steps (like NumPy's linspace), may be with the notation a..b::N or something?

joshichaitanya3 commented 2 years ago

I just realized that the above example isn't the greatest, since we can just do 0..1:(1/(N+1)) and it works, but there are other spots where it could be more useful.

ConduitDan commented 2 years ago

If you want to do this you can do it with Matrix(List(range))/N

We might want to consider a constructor of type Matrix(range) (and Array(range)) to avoid the call to list first?

eihabhala commented 1 year ago

Nice

eihabhala commented 1 year ago

I am seeing something Amazing with this language. But the Question is How to Build Packages For It appreciated if You Guys Can Point Me With Just That :)

softmattertheory commented 9 months ago

@eihabhala Thanks for the feedback! We are working on detailed information for developers, including how to build packages for our upcoming release.

eihabhala commented 9 months ago

Thanks 💐