Fuzion Logo
fuzion-lang.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:
f(r, a f64) (f64, f64) => (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, A2 type, f1 A1, f2  A2, ... ) is
The above function could be mapped into
tuple f64 f64 (f(r, a f64) => tuple(r * (cos a), r * (sin a)))
Which can then be called as follows
  xy := f 1 (math.pi / 4)
  draw_point xy.values.1 xy.values.2
An easy way to destructure a tuple simplifies the syntax to
  (x, y) := f 1 (math.pi / 4)
  draw_point x y