My question is fairly simple, but I'm quite new to MiniZinc so that's why I'm asking.
I want to define a function even that, given an argument i, returns a list with the even numbers from 0 to 2i.
For example,
even(4)=[0,2,4,6,8]
Can you tell the code for such function?
This problem can be solved quickly using an array comprehension:
function array[int] of int: even(int: n) =
[ 2*i | i in 0..n];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.