<commit_before>// Swift Operators - http://nshipster.com/swift-operators/

import Cocoa

// Overloading

func * (left: String, right: Int) -> String {
    if right <= 0 {
        return ""
    }
    
    var result = left
    for _ in 1..<right {
        result += left
    }
    
    return result
}

"a" * 6

// overloading can be used for evil
[1, 2] + [3, 4]

func +(left: [Double], right: [Double]) -> [Double] {
    var sum = [Double](count: left.count, repeatedValue: 0.0)
    for (i, _) in enumerate(left) {
        sum[i] = left[i] + right[i]
    }
    
    return sum
}
println("\([1, 2] + [3, 4])")

func +(left: [Int], right: [Int]) -> [Int] {
    var sum = [Int](count: left.count, repeatedValue: 0)
    for (i, _) in enumerate(left) {
        sum[i] = left[i] + right[i]
    }
    
    return sum
}

println("\([1, 2] + [3, 4])")


// I'm specifically concerned about the semantics of array operators, as demonstrated in the previous example. My 2 cents: arrays should forego the + and - operators in lieu of <<:

func <<<T> (inout left: [T], right: [T]) -> [T] {
    //left.extend(right)
    return left
}

func <<<T> (inout left: [T], right: T) -> [T] {
    //left.append(right)
    return left
}

[1,2,3,4]<<[5,6]
[1,2,3,4]<<5<commit_msg>Time for bed<commit_after>// Swift Operators - http://nshipster.com/swift-operators/

import Cocoa

// Overloading

func * (left: String, right: Int) -> String {
    if right <= 0 {
        return ""
    }
    
    var result = left
    for _ in 1..<right {
        result += left
    }
    
    return result
}

"a" * 6

// overloading can be used for evil
[1, 2] + [3, 4]

func +(left: [Double], right: [Double]) -> [Double] {
    var sum = [Double](count: left.count, repeatedValue: 0.0)
    for (i, _) in enumerate(left) {
        sum[i] = left[i] + right[i]
    }
    
    return sum
}
println("\([1, 2] + [3, 4])")

func +(left: [Int], right: [Int]) -> [Int] {
    var sum = [Int](count: left.count, repeatedValue: 0)
    for (i, _) in enumerate(left) {
        sum[i] = left[i] + right[i]
    }
    
    return sum
}

println("\([1, 2] + [3, 4])")


// I'm specifically concerned about the semantics of array operators, as demonstrated in the previous example. My 2 cents: arrays should forego the + and - operators in lieu of <<:

func <<<T> (inout left: [T], right: [T]) -> [T] {
    //left.extend(right)
    return left
}

func <<<T> (inout left: [T], right: T) -> [T] {
    //left.append(right)
    return left
}

//[1,2,3,4]<<[5,6]
//[1,2,3,4]<<5
{'fraction_non_alphanumeric': 0.1878233187425388, 'fraction_numerical': 0.0238758456028651, 'mean_word_length': 2.4675862068965517, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 17, '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': '1891548', 'n_tokens_mistral': 985, 'n_tokens_neox': 942, 'n_words': 281}