ngs-lang / ngs

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

Add ensure(Int, NumRange) #488 #591

Closed antonio-pedro99 closed 1 year ago

antonio-pedro99 commented 1 year 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 1 year 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 1 year ago

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

ilyash-b commented 1 year ago

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