<commit_before>augment class List {
    method elems() { +self!generate; }

    method list() { self; }

    method Num() { self.elems; }

    method Int() { self.elems.Int; }

    method Str() {
        pir::join(' ', self!generate);
    }

    method perl() {
        if self.elems() == 0 { return Nil.WHAT };
        # XXX: $_.perl and .perl don't work, but this does...
        '(' ~ self.map({ $^a.perl }).join(', ') ~ ')';
    }
}

# vim: ft=perl6<commit_msg>Start throwing iterator example code into List.pm.  Compiles but not tested or used for anything.<commit_after>augment class List {
    method elems() { +self!generate; }

    method list() { self; }

    method Num() { self.elems; }

    method Int() { self.elems.Int; }

    method Str() {
        pir::join(' ', self!generate);
    }

    method perl() {
        if self.elems() == 0 { return Nil.WHAT };
        # XXX: $_.perl and .perl don't work, but this does...
        '(' ~ self.map({ $^a.perl }).join(', ') ~ ')';
    }
}

# Throw together an iterator interface, just so we have something to talk about

role Iterator {
    multi method get() {
        Nil; # probably should use a special terminator instead
    }

    multi method list() {
        self;
    }
}

class ScalarIterator does Iterator {
    has $.value;
    has $.done;

    multi method new($value) {
        self.bless(*, :value($value),
                      :done(Bool::False));
    }

    multi method get() {
        if $.done {
            Nil;
        }
        else {
            $.done = Bool::True;
            $.value;
        }
    }
}


# vim: ft=perl6
{'fraction_non_alphanumeric': 0.15619166148102054, 'fraction_numerical': 0.002489110143123833, 'mean_word_length': 1.907775768535262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7010833', 'n_tokens_mistral': 538, 'n_tokens_neox': 501, 'n_words': 147}