<commit_before>doc "Don't forget to document me"
by "gavin"
shared class Tuple<out Element, out First, out Rest>(first, rest)
        extends Object()
        satisfies Sequence<Element>
        given First satisfies Element
        given Rest satisfies Element[] {
        
    shared actual First first;
    shared actual Rest&Element[] rest;
    
    shared actual Element? item(Integer index) {
        switch (index<=>0)
        case (smaller) { return null; }
        case (equal) { return first; }
        case (larger) { return rest.item(index-1); }
    }
    
    shared actual Integer lastIndex {
        if (exists restLastIndex = rest.lastIndex) {
            return restLastIndex+1;
        }
        else {
            return 0;
        }
    }
    
    shared actual Sequence<Element> reversed =>
            rest.reversed.withTrailing(first);
    
    shared actual Element[] segment(Integer from, Integer length) {
        if(length < 0)
            return {};
        Integer realFrom = max(0, from);
        if (realFrom==0) {
            return length==1 then {first}
                else rest[0:length+realFrom-1].withLeading(first);
        }
        return rest[realFrom-1:length];
    }
    
    shared actual Element[] span(Integer from, Integer end) {
        Integer realFrom = max(0, from);
        return realFrom<=end then this[from:end-realFrom+1] 
                else this[end:realFrom-end+1].reversed.sequence;
    }
    shared actual Element[] spanTo(Integer to) =>
        to<0 then {} else span(0, to);
    shared actual Element[] spanFrom(Integer from) =><commit_msg>Tuple: fixed syntax mistakes<commit_after>doc "Don't forget to document me"
by "gavin"
shared class Tuple<out Element, out First, out Rest>(first, rest)
        extends Object()
        satisfies Sequence<Element>
        given First satisfies Element
        given Rest satisfies Element[] {
        
    shared actual First first;
    shared actual Rest&Element[] rest;
    
    shared actual Element? item(Integer index) {
        switch (index<=>0)
        case (smaller) { return null; }
        case (equal) { return first; }
        case (larger) { return rest.item(index-1); }
    }
    
    shared actual Integer lastIndex {
        if (exists restLastIndex = rest.lastIndex) {
            return restLastIndex+1;
        }
        else {
            return 0;
        }
    }
    
    shared actual Sequence<Element> reversed =>
            rest.reversed.withTrailing(first);
    
    shared actual Element[] segment(Integer from, Integer length) {
        if(length < 0){
            return {};
        }
        Integer realFrom = from < 0 then 0 else from;
        if (realFrom==0) {
            return length==1 then {first}
                else rest[0:length+realFrom-1].withLeading(first);
        }
        return rest[realFrom-1:length];
    }
    
    shared actual Element[] span(Integer from, Integer end) {
        Integer realFrom = from < 0 then 0 else from;
        return realFrom<=end then this[from:end-realFrom+1] 
                else this[end:realFrom-end+1].reversed.sequence;
    }
    shared actual Element[] spanTo(Integer to) =>
        to<0 then {} else span(0, to);
    shared actual Element[] spanFrom(Integer from) =>
{'fraction_non_alphanumeric': 0.10147148988350706, 'fraction_numerical': 0.010423053341508276, 'mean_word_length': 2.1284755512943434, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '6938219', 'n_tokens_mistral': 920, 'n_tokens_neox': 897, 'n_words': 271}