>>16
a simple example...
imperative/side-effects: (C)
void double(int* ar, int size)
{
for (int i = 0; i < size; ++i)
{
ar[i] = ar[i] * 2;
}
}
functional/basically needs GC (Scheme)
(define (double lst)
(map (lambda(x) (* 2 x)) lst))
the second returns a new list with doubled contents. The first modifies the list in place. The second has no side effects on anything. (of course, under the hood, the CPU's state is changing a lot, but you never have to think about it.)
basically it's about using arguments and return values. things that help you code this way are: lambda, GC.