Permalink
Browse files

style point: don't reuse 'first' and 'last' in this data structure, i…

…t confuses the structure with a Link.
  • Loading branch information...
crdrost committed Jan 26, 2012
1 parent 8f6c79b commit b404a9f995a16a61cd3c4b6e23de5b417cc95ee9
Showing with 4 additions and 5 deletions.
  1. +4 −5 programs/recursive_reverse.js
@@ -75,15 +75,14 @@ function bad_reverse2(list) {
var base;
if (ls.rest === undefined) {
base = new Link(ls.first, undefined);
- return {first: base, last: base};
+ return {links: base, last_link: base};
} else {
base = subreverse(ls.rest);
- base.last.rest = new Link(ls.first, undefined);
- base.last = base.last.rest;
- return base;
+ base.last_link.rest = new Link(ls.first, undefined);
+ return {links: base.links, last_link: base.last_link.rest};
}
}
- return subreverse(list).first;
+ return subreverse(list).links;
}
bad_reverse2(Link.from_array([7,8,9,10])).to_array();
// [10, 9, 8, 7]

0 comments on commit b404a9f

Please sign in to comment.