Changes

Jump to: navigation, search

GPU621/The Chapel Programming Language

771 bytes added, 14:14, 20 November 2020
Iterators
=== Iterators ===
 
Chapel implements iterators using a function-like syntax, although the semantic behaviour of an iterator differs from that of a function in some important ways. Unlike functions, instead of returning a value, Chapel iterators typically return a sequence of values. The '''yield''' statement, legal only within iterator bodies, returns a value and temporarily suspends the execution of the code within the iterator.
 
As an example, the following Chapel code defines a trivial iterator that yields the first n values from the Fibonacci sequence:
 
iterator fibonacci(n): integer {
var i1 = 0, i2 = 1;
var i = 0;
while i <= n {
yield i1;
var i3 = i1 + i2;
i1 = i2;
i2 = i3;
i += 1;
}
}
 
=== Task Parallelism ===
=== Locality ===
25
edits

Navigation menu