Better HN
topnewbestaskshowjobs
Log inSign up

hqm42

2 karma · joined Feb 21, 2013 (13y ago) · 2 submissions

Submissions

comment 13y ago · link · parent

Revision 22 revealed that something went terribly wrong...

comment 13y ago · link · parent

  LinkedList.prototype.reverse = function () {
    var rev = function(e,tail) {
      if (!e) {
        return tail;
      } else {
        var next = e.next;
        e.next = tail;
        return rev(next, e);
      }
    };
    this.head = rev(this.head, null);
  };