Add check in from_to_step #814

Merged
zxq9 merged 3 commits from fromtostep into master 2021-07-05 16:39:33 +09:00
Showing only changes of commit b366bed24b - Show all commits

View File

@ -80,6 +80,7 @@ namespace List =
* `b` only if `(b - a) mod step == 0`. `step` should be bigger than 0.
*/
function from_to_step(a : int, b : int, s : int) : list(int) =
require(step > 0, "List.from_to_step: non-positive step")
from_to_step_(a, b - (b-a) mod s, s, [])
private function from_to_step_(a : int, b : int, s : int, acc : list(int)) : list(int) =
if(b < a) acc