Title here
Summary here
Functions are central in Chapel. We’ll learn about functions with a few different examples.
To run the program, save it as functions.chpl
and use the Chapel compiler:
In Chapel, functions are called procedures and are defined using the proc
keyword. The syntax is slightly different from other languages, but the concept is similar. Chapel uses type inference, but we’ve explicitly declared types here for clarity.
Chapel doesn’t have a built-in fmt
module like in the original example, so we use the IO
module and its writeln
function for output.
There are several other features to Chapel functions. One is multiple return values, which we’ll look at next.