Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Simple made easy

Name: Anonymous 2011-10-21 10:06

http://www.infoq.com/presentations/Simple-Made-Easy

Rich Hickey's presentation which received a standing ovation from Dr. Sussman.

Name: Anonymous 2011-10-21 18:27

>>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.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List