<commit_before>//  Copyright (c) 2015 <NAME>. All rights reserved.

public struct Environment: CollectionType, DictionaryLiteralConvertible, Printable {
	private var bindings: Dictionary<Symbol, Value>

	public subscript (key: String) -> (Symbol, Value)? {
		let index = find(bindings) { symbol, _ in symbol.name == key }
		return index.map { self.bindings[$0] }
	}

	public subscript (key: Symbol) -> Value? {
		get { return bindings[key] }
		set { bindings[key] = newValue }
	}


	// MARK: CollectionType

	public var startIndex: Dictionary<Symbol, Value>.Index {
		return bindings.startIndex
	}

	public var endIndex: Dictionary<Symbol, Value>.Index {
		return bindings.endIndex
	}

	public subscript (index: Dictionary<Symbol, Value>.Index) -> (Symbol, Value) {
		return bindings[index]
	}


	// MARK: DictionaryLiteralConvertible

	public init(dictionaryLiteral elements: (Symbol, Value)...) {
		bindings = Dictionary(elements)
	}


	// MARK: Printable

	public var description: String {
		return "[\n" + join("", lazy(bindings).map { "\t\(toString($0)): \(toString($1)),\n" }) + "]"
	}


	// MARK: SequenceType

	public func generate() -> IndexingGenerator<Environment> {
		return IndexingGenerator(self)
	}
}

public func + (var left: Environment, right: (Symbol, Value)) -> Environment {
	left[right.0] = right.1
	return left
}


// MARK: - Prelude

public let Prelude: Environment = [
	Symbol("unit", .Unit): Value(constant: ()),
	Symbol("true", .Boolean): Value(constant: true),
	Symbol("false", .Boolean): Value(constant: false),
	Symbol("identity", 0 --> 0): Value(function: id as Any -> Any),
	Symbol("constant", 0 --> 1 --> 0): Value(function: const as Any -> Any -> Any),
]


// MARK: - Imports

import Prelude
<commit_msg>Use Manifold’s Term in Environment.<commit_after>//  Copyright (c) 2015 <NAME>. All rights reserved.

public struct Environment: CollectionType, DictionaryLiteralConvertible, Printable {
	private var bindings: Dictionary<Symbol, Value>

	public subscript (key: String) -> (Symbol, Value)? {
		let index = find(bindings) { symbol, _ in symbol.name == key }
		return index.map { self.bindings[$0] }
	}

	public subscript (key: Symbol) -> Value? {
		get { return bindings[key] }
		set { bindings[key] = newValue }
	}


	// MARK: CollectionType

	public var startIndex: Dictionary<Symbol, Value>.Index {
		return bindings.startIndex
	}

	public var endIndex: Dictionary<Symbol, Value>.Index {
		return bindings.endIndex
	}

	public subscript (index: Dictionary<Symbol, Value>.Index) -> (Symbol, Value) {
		return bindings[index]
	}


	// MARK: DictionaryLiteralConvertible

	public init(dictionaryLiteral elements: (Symbol, Value)...) {
		bindings = Dictionary(elements)
	}


	// MARK: Printable

	public var description: String {
		return "[\n" + join("", lazy(bindings).map { "\t\(toString($0)): \(toString($1)),\n" }) + "]"
	}


	// MARK: SequenceType

	public func generate() -> IndexingGenerator<Environment> {
		return IndexingGenerator(self)
	}
}

public func + (var left: Environment, right: (Symbol, Value)) -> Environment {
	left[right.0] = right.1
	return left
}


// MARK: - Prelude

public let Prelude: Environment = [
	Symbol("unit", .Unit): Value(constant: ()),
	Symbol("true", .Bool): Value(constant: true),
	Symbol("false", .Bool): Value(constant: false),
	Symbol("identity", Term.forall([0], Term.function(Term(0), Term(0)))): Value(function: id as Any -> Any),
	Symbol("constant", Term.forall([0, 1], Term.function(Term(0), Term.function(Term(1), Term(0))))): Value(function: const as Any -> Any -> Any),
]


// MARK: - Imports

import Prelude
import Manifold

{'fraction_non_alphanumeric': 0.1583171879324661, 'fraction_numerical': 0.008580127318018268, 'mean_word_length': 4.230101302460203, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 34, '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': '3373507', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1105, 'n_words': 313}