Title here
Summary here
Chapel has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
use IO;
proc main() {
// Strings, which can be added together with +.
writeln("chapel" + "lang");
// Integers and floats.
writeln("1+1 = ", 1 + 1);
writeln("7.0/3.0 = ", 7.0 / 3.0);
// Booleans, with boolean operators as you'd expect.
writeln(true && false);
writeln(true || false);
writeln(!true);
}
To run the program, save it as values.chpl
and use the chpl
compiler:
$ chpl values.chpl -o values
$ ./values
chapellang
1+1 = 2
7.0/3.0 = 2.33333
false
true
false
In this Chapel program:
IO
module for input/output operations.proc main()
defines the main procedure, similar to other languages’ main functions.writeln()
for printing to the console, which is similar to println()
in other languages.//
for single-line comments.Chapel’s syntax is quite similar to C-style languages, making it relatively easy to read and write for those familiar with such languages.