ExpandCollapsePrev Next Index

+ 12.1 Basic Data types

To get moving we give some basic data types:

  Type        Example Values        
  ---------------------------------------
  void                              void is also called 0, it has no values (empty set)
  unit        ()                    unit is also called 1, it has 1 value.
  bool        false, true           bool is also called 2, it has 2 values.
                                    Named for George Boole.

  int         1234, 0, -24
  double      12.34,  -2.0e2, 7.6e-2, 0.0
  string      "hello", 'world'
  char        char 'x', char 32

Note that there are no char literals, instead the char constructor takes a string and provides the first character (if there is one) or the nul character if the string is empty.

+ 12.2 Type aliases

In Felix you can introduce an alias for a type:

  typedef myint = int;
  typedef int_pair = int * int;

+ 12.3 Basic functions

Some simple functions that are fairly general and quite useful:

+ 12.3.1 str and repr

The str function converts many data types into a pleasant human readable string. The repr function tries to make a string a bit more like a literal would look in a program. Thus:

  val x="Hello";
  println$ str x; // Hello
  println$ repr x; // "Hello"

The concept is stolen from Python.