/ tests / tests / compiler / examples / groups.adl
groups.adl
 1  
 2  program test.alpha {
 3      // This function takes a group coordinate as input `a` and performs several operations which should output the `0group`.
 4      // Note that the operations can be called as associated functions on the `a` variable.
 5  
 6      transition main(a: group) -> group {
 7          // unary
 8          let b: group = a.double(); // 2a
 9          let c: group = b.neg();    // -2a
10  
11          // binary
12          let d: group = (a * 2scalar).add(c);
13  
14          // generator
15          let e: group = group::GEN;
16  
17          return d + e;
18      }
19  }
20