Oh my, silly code, yes. Sorry.
function* iter() {
if (this.left) {
yield* iter.call(this.left);
// OR: yield* this.left[iterator]();
}
yield this.label;
if (this.right) {
yield* iter.call(this.right);
}
}
Tree.prototype[iterator] = iter;
On May 10, 2012, at 23:22 , Erik Arvidsson wrote:
> On Thu, May 10, 2012 at 2:16 PM, Axel Rauschmayer <[email protected]> wrote:
>> function* iter() {
>>
>> if (this.left) {
>>
>> yield* iter(this.left);
>
> I'm confused how you expect this to work. iter does not take a parameter.
>
>> }
>>
>> yield this.label;
>>
>> if (this.right) {
>>
>> yield* iter(this.right);
>>
>> }
>>
>> }
>>
>>
>> Tree.prototype.visit = visit;
>>
>> Tree.prototype[iterator] = iter;
>
> Maybe you intended to write something like this?
>
> function* iter(tree) {
> if (tree.left) {
> yield* iter(tree.left);
> }
> yield tree.label;
> if (tree.right) {
> yield* iter(tree.right);
> }
> }
>
> --
> erik
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss