<commit_before>// Range object

package py

// A python Range object
// FIXME one day support BigInts too!
type Range struct {
	Start Int
	Stop  Int
	Step  Int
	//Length Object
}

// A python Range iterator
type RangeIterator struct {
	Range
	Index Int
}

var RangeType = NewTypeX("range", `range(stop) -> range object
range(start, stop[, step]) -> range object

Return a virtual sequence of numbers from start to stop by step.`,
	RangeNew, nil)

var RangeIteratorType = NewType("range_iterator", `range_iterator object`)

// Type of this object
func (o *Range) Type() *Type {
	return RangeType
}

// Type of this object
func (o *RangeIterator) Type() *Type {
	return RangeIteratorType
}

// RangeNew
func RangeNew(metatype *Type, args Tuple, kwargs StringDict) Object {
	var start Object
	var stop Object
	var step Object = Int(1)
	UnpackTuple(args, kwargs, "range", 1, 3, &start, &stop, &step)
	if len(args) == 1 {
		return &Range{
			Start: Int(0),
			Stop:  Index(start),
			Step:  Int(1),
		}
	}
	return &Range{
		Start: Index(start),
		Stop:  Index(stop),
		Step:  Index(step),
	}
}

// Make a range iterator from a range
func (r *Range) M__iter__() Object {
	return &RangeIterator{
		Range: *r,
		Index: r.Start,
	}
}

// Range iterator
func (it *RangeIterator) M__iter__() Object {
	return it
}

// Range iterator next
func (it *RangeIterator) M__next__() Object {
	r := it.Index
	if r >= it.Stop {
		panic(StopIteration)
	}
	it.Index++
	return r<commit_msg>Fix range object to step correctly<commit_after>// Range object

package py

// A python Range object
// FIXME one day support BigInts too!
type Range struct {
	Start Int
	Stop  Int
	Step  Int
	//Length Object
}

// A python Range iterator
type RangeIterator struct {
	Range
	Index Int
}

var RangeType = NewTypeX("range", `range(stop) -> range object
range(start, stop[, step]) -> range object

Return a virtual sequence of numbers from start to stop by step.`,
	RangeNew, nil)

var RangeIteratorType = NewType("range_iterator", `range_iterator object`)

// Type of this object
func (o *Range) Type() *Type {
	return RangeType
}

// Type of this object
func (o *RangeIterator) Type() *Type {
	return RangeIteratorType
}

// RangeNew
func RangeNew(metatype *Type, args Tuple, kwargs StringDict) Object {
	var start Object
	var stop Object
	var step Object = Int(1)
	UnpackTuple(args, kwargs, "range", 1, 3, &start, &stop, &step)
	if len(args) == 1 {
		return &Range{
			Start: Int(0),
			Stop:  Index(start),
			Step:  Int(1),
		}
	}
	return &Range{
		Start: Index(start),
		Stop:  Index(stop),
		Step:  Index(step),
	}
}

// Make a range iterator from a range
func (r *Range) M__iter__() Object {
	return &RangeIterator{
		Range: *r,
		Index: r.Start,
	}
}

// Range iterator
func (it *RangeIterator) M__iter__() Object {
	return it
}

// Range iterator next
func (it *RangeIterator) M__next__() Object {
	r := it.Index
	if r >= it.Stop {
		panic(StopIteration)
	}
	it.Index += it.Step
	return r
{'fraction_non_alphanumeric': 0.12120189061444969, 'fraction_numerical': 0.004051316677920324, 'mean_word_length': 3.6661417322834646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6107034', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1016, 'n_words': 361}