<commit_before>package recurrent

import "time"

// Create a channel that has values pushed to it in a rapid loop
// until a value is received on the given quit channel.
func hammer(quit <-chan struct{}) chan struct{} {
	ch := make(chan struct{})

	go func() {
		defer close(ch)

		for {
			select {
			case ch <- struct{}{}:
			case <-quit:
				return
			}
		}
	}()

	return ch
}

// Convert a ticker channel to a struct{} channel.
func convert(ch1 <-chan time.Time) chan struct{} {
	ch2 := make(chan struct{})

	go func() {
		defer close(ch2)

		for _ = range ch1 {
			ch2 <- struct{}{}
		}
	}()

	return ch2
}

// Create a channel which receives a value once a value is ready
// from both ch1 and ch2. The channel is closed once ch1 closes.
func throttle(ch1 chan struct{}, ch2 chan struct{}) chan struct{} {
	ch3 := make(chan struct{})

	go func() {
		defer close(ch3)

		for _ = range ch1 {
			ch3 <- <-ch2
		}
	}()

	return ch3
}<commit_msg>Simplify channel operations.<commit_after>package recurrent

import "time"

// Create a channel that has values pushed to it in a rapid loop
// until a value is received on the given quit channel.
func hammer(quit <-chan struct{}) chan struct{} {
	ch := make(chan struct{})

	go func() {
		defer close(ch)

		for {
			select {
			case ch <- struct{}{}:
			case <-quit:
				return
			}
		}
	}()

	return ch
}

// Convert a ticker channel to a struct{} channel.
func convert(ch1 <-chan time.Time) chan struct{} {
	ch2 := make(chan struct{})

	go func() {
		defer close(ch2)

		for range ch1 {
			ch2 <- struct{}{}
		}
	}()

	return ch2
}

// Create a channel which receives a value once a value is ready
// from both ch1 and ch2. The channel is closed once ch1 closes.
func throttle(ch1 chan struct{}, ch2 chan struct{}) chan struct{} {
	ch3 := make(chan struct{})

	go func() {
		defer close(ch3)

		for range ch1 {
			ch3 <- <-ch2
		}
	}()

	return ch3
}
{'fraction_non_alphanumeric': 0.12887953708574434, 'fraction_numerical': 0.01788532351394003, 'mean_word_length': 2.8658536585365852, 'pattern_counts': {'":': 0, '<': 17, '<?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': '1138649', 'n_tokens_mistral': 729, 'n_tokens_neox': 623, 'n_words': 252}