<commit_before>package vm

import "reflect"

type Object interface{}

type Callable interface {
	Call(...*Thunk) *Thunk
}

type Equalable interface {
	Equal(Equalable) bool
}

func Equal(ts ...*Thunk) *Thunk {
	for _, t := range ts {
		go t.Eval()
	}

	e0, ok := ts[0].Eval().(Equalable)

	if !ok {
		return notEqualableError(e0)
	}

	for _, t := range ts[1:] {
		if e, ok := t.Eval().(Equalable); !ok {
			return notEqualableError(e)
		} else if reflect.TypeOf(e0) != reflect.TypeOf(e) || !e0.Equal(e) {
			return False
		}
	}

	return True
}

func notEqualableError(o Object) *Thunk {
	return TypeError(o, "Equalable")
}<commit_msg>Add add<commit_after>package vm

import "reflect"

type Object interface{}

type Callable interface {
	Call(...*Thunk) *Thunk
}

type Equalable interface {
	Equal(Equalable) bool
}

func Equal(ts ...*Thunk) *Thunk {
	for _, t := range ts {
		go t.Eval()
	}

	o := ts[0].Eval()
	e0, ok := o.(Equalable)

	if !ok {
		return notEqualableError(o)
	}

	for _, t := range ts[1:] {
		if e, ok := t.Eval().(Equalable); !ok {
			return notEqualableError(e)
		} else if reflect.TypeOf(e0) != reflect.TypeOf(e) || !e0.Equal(e) {
			return False
		}
	}

	return True
}

func notEqualableError(o Object) *Thunk {
	return TypeError(o, "Equalable")
}

type Addable interface {
	Add(Addable) Addable
}

func Add(ts ...*Thunk) *Thunk {
	for _, t := range ts {
		go t.Eval()
	}

	o := ts[0].Eval()
	a0, ok := o.(Addable)

	if !ok {
		return TypeError(o, "Addable")
	}

	for _, t := range ts[1:] {
		o := t.Eval()

		if typ := reflect.TypeOf(a0); typ != reflect.TypeOf(o) {
			return TypeError(o, typ.Name())
		}

		a0 = a0.Add(o.(Addable))
	}

	return Normal(a0)
}
{'fraction_non_alphanumeric': 0.17202380952380952, 'fraction_numerical': 0.010714285714285714, 'mean_word_length': 3.31025641025641, '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': '323882', 'n_tokens_mistral': 728, 'n_tokens_neox': 679, 'n_words': 168}