<commit_before>import Foundation

extension Optional {
	func reduce<U>(initial: U, combine: (U, T) -> U) -> U {
		switch self {
		case .None:
			return initial
		case .Some(let value):
			return combine(initial, value)
		}
	}
	
	func filter(includeElement: T -> Bool) -> T? {
		return flatMap { includeElement($0) ? $0 : nil }
	}
	
	func each(action: T -> ()) {
		reduce(()) { action($1) }
	}
}

extension Array {
	func each(action: T -> ()) {
		reduce(()) { action($1) }
	}
    
    func flatMap<U>(transform: T -> U?) -> [U] {
        return flatMap { transform($0).map { [$0] } ?? [] }
    }
}<commit_msg>Add @noescape<commit_after>import Foundation

extension Optional {
	func reduce<U>(initial: U, @noescape combine: (U, T) -> U) -> U {
		switch self {
		case .None:
			return initial
		case .Some(let value):
			return combine(initial, value)
		}
	}
	
	func filter(@noescape includeElement: T -> Bool) -> T? {
		return flatMap { includeElement($0) ? $0 : nil }
	}
	
	func each(@noescape action: T -> ()) {
		reduce(()) { action($1) }
	}
}

extension Array {
	func each(@noescape action: T -> ()) {
		reduce(()) { action($1) }
	}
    
    func flatMap<U>(@noescape transform: T -> U?) -> [U] {
        return flatMap { transform($0).map { [$0] } ?? [] }
    }
}
{'fraction_non_alphanumeric': 0.1895734597156398, 'fraction_numerical': 0.009478672985781991, 'mean_word_length': 2.874617737003058, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '4908846', 'n_tokens_mistral': 486, 'n_tokens_neox': 450, 'n_words': 116}