top of page

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

  • 執筆者の写真: MSI株式会社
    MSI株式会社
  • 2022年5月13日
  • 読了時間: 1分

更新日:2022年6月7日

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

最新記事

すべて表示

Komentarze


bottom of page