Fuzion Logo
flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Fuzion Tuples

Tuples are basically unnamed product types, they can be implemented using pure syntactic sugar as follows:
  (f64, f64) f(f64 r, f64 a) => (r * cos(a), r * sin(a));
which defines a function f that converts polar coordinates radius r and angle a into Euclidean coordinates x and y without defining a particular type for this. Using a generic feature
  tuple (A1 f1, A2 f2, ... ) { }
The above function could be mapped into
 tuple f(f64 r, f64 a) => tuple(r * cos(a), r * sin(a));
Which can then be called as follows
  xy := f(1, Math.pi / 4);
  drawPoint(xy.f1, xy.f2);
An easy way to destructure a tuple simplifies the syntax to
  (x, y) := f(1, Math.pi / 4);
  drawPoint(x, y);