top of page

Q:Is it possible too loop over elements of alist and use the values as indices?

Q: Is it possible too loop over elements of alist and use the values as indices?

Example:

A[0..29] = inFile.readInt();

x <- list(30);

// some constraints for x

result <- sum[i in x](A[i]);

maximize result;


A:Yes, you can do this using

In your example, you canwrite:

A[0..29] = inFile.readInt();

x <- list(30);

// some constraints for x

result <- sum(x, i => A[i]);

maximize result;


A good use case of

lambda functions can be

found for instance

最新記事

すべて表示
bottom of page