ngs-lang / ngs

Next Generation Shell (NGS)
https://ngs-lang.org/
GNU General Public License v3.0
1.49k stars 41 forks source link

Add ensure(Int, NumRange) #488 #591

Closed antonio-pedro99 closed 2 years ago

antonio-pedro99 commented 2 years ago

Not really sure what to do with ranges that does not include an end. But my assumption is if a range spans to infinity and the first element in the range is less than n, we should return the first element otherwise return the n.

ilyash-b commented 2 years ago

Not really sure what to do with ranges that does not include an end. But my assumption is if a range spans to infinity and the first element in the range is less than n, we should return the first element otherwise return the n.

If n is between beginning of the range and end of the range, the result should be n. If range spans to infinity and the first element in the range is less than n it means that n is in the range.

ilyash-b commented 2 years ago

I guess a good start of the function would be something like n in r returns n

ilyash-b commented 2 years ago

Also please add appropriate entry in the changelog file (root folder of the repo)