Is `[ in ]` equivalent to `foral

2019-02-24 01:08发布

I noticed something in a snippet of code I was given:

var D: domain(2) dmapped Block(boundingBox=Space) = Space;
var A: [D] int;
[a in A] a = a.locale.id;

Is [a in A] equivalent to forall a in A a = a.locale.id?

标签: syntax chapel
1条回答
我只想做你的唯一
2楼-- · 2019-02-24 01:57

Yes, exactly. In Chapel, [a in A] expr is equivalent to forall a in A do expr.

With respect to the title of this question, note that this is independent of whether or not A is distributed. For example, you could also write [i in 1..n] rather than forall i in 1..n do.

Array types in Chapel, like [D] real can similarly be read as

"for all indices in D, allocate an element of type real."

查看更多
登录 后发表回答