/* vim:set ts=2 sw=2 sts=2 expandtab */
/*jshint asi: true undef: true es5: true node: true browser: true devel: true
         forin: true latedef: false globalstrict: true */
'use strict';

var sequence = require('./sequence'),
    isEmpty = sequence.isEmpty, count = sequence.count,
    first = sequence.first, rest = sequence.rest,
    cons = sequence.cons, make = sequence.make, empty = sequence.empty

function List() {}
List.prototype.length = 0
List.prototype.toString = function() {
  var value = '', tail = this;
  while (!isEmpty(tail)) {
    value = value + ' ' + first(tail)
    tail = rest(tail)
  }

  return '(' + value.substr(1) + ')'
}

count.define(List, function(list) { return list.length })
first.define(List, function(list) { return list.head })
rest.define(List, function(list) { return list.tail })
make.define(List, function(tail, head) { return new List(head, tail) })

function list() {
  var items = arguments, count = items.length, tail = empty
  while (count--) tail = cons(items[count], tail)
  return tail
}
exports.list = list

@@ -414,19 +414,109 @@
 on List(
-) %7B
+head, tail) %7B%0A  this.head = head%0A  this.tail = tail %7C%7C empty%0A  this.length = count(tail) + 1%0A
 %7D%0AList.p
@@ -735,16 +735,36 @@
  + ')'%0A%7D
+%0Aexports.List = List
 %0A%0Acount.

Change `List` so that it sets it's head, tail and `length` properties & export it from module.