Next: Vector operations Up: Sample session Previous: Sample session

### Scalar operations

```<Nesl> 2 * (3 + 4);

it = 14 : int
<Nesl> set verbose off;     % turns off verbose compiler messages %

<Nesl> (2.2 + 1.1) / 5.0;

it = 0.66 : float
<Nesl> t or f;

it = T : bool
<Nesl> `a < `d;     % that's a backquote, not a quote %

it = T : bool
<Nesl> 3;

it = 3 : int
<Nesl> 1.6 + 7;     % these aren't the same type %

Error at top level.
For function + in expression
1.6 + 7
inferred argument types don't match function specification.
Argument types: float, int
Function types: a, a :: (a in number)

<Nesl> 1.6 + float(7);

it = 8.6 : float
<Nesl> sin(.6);

it = 0.564642473395035 : float
<Nesl> a = 4;

a = 4 : int
<Nesl> a + 5;

it = 9 : int
<Nesl> if (4 < 5) then 11 else 12;

it = 11 : int
<Nesl> let a = 3 * 4   % the '>' is a prompt for you to enter more %
>      in a + (a * 5);

it = 72 : int
<Nesl> let a = 3 * 4;
>          b = a + 5
>      in a + b;

it = 29 : int
<Nesl> function fact(i) =    % you can define functions at top level %
>        if (i == 1)
>        then 1
>        else i * fact(i-1);

fact = fn : int -> int
<Nesl> fact(5);

it = 120 : int

<Nesl> function circarea(r) = pi * r * r;     % pi is predefined %

circarea = fn : float -> float
<Nesl> circarea(3.0);

it = 28.2743338823081 : float
<Nesl> (2, `a);

it = (2, `a) : int, char
<Nesl> function div_rem(a, b) = (a / b, rem(a, b));

div_rem = fn : (int, int) -> (int, int)
<Nesl> div_rem (20, 6);

it = (3, 2) : int, int
```

Guy Blelloch
Tue Nov 28 18:37:09 EST 1995