<commit_before>//
//    ___    ___       __   ___  ________ _________
//  _|\  \__|\  \     |\  \|\  \|\  _____\\___   ___\
// |\   ____\ \  \    \ \  \ \  \ \  \__/\|___ \  \_|
// \ \  \___|\ \  \  __\ \  \ \  \ \   __\    \ \  \
//  \ \_____  \ \  \|\__\_\  \ \  \ \  \_|     \ \  \
//   \|____|\  \ \____________\ \__\ \__\       \ \__\
//     ____\_\  \|____________|\|__|\|__|        \|__|
//    |\___    __\
//    \|___|\__\_|
//         \|__|
//
//  $.swift
//  Dollar - A functional tool-belt for Swift Language
//
//  Created by <NAME> on 6/3/14.
//  Copyright (c) 2014 Encore Dev Labs LLC. All rights reserved.
//

import Foundation

class $ {
    
    //  ________  ___  ___  ________  ___  ________
    // |\   ____\|\  \|\  \|\   __  \|\  \|\   ___  \
    // \ \  \___|\ \  \\\  \ \  \|\  \ \  \ \  \\ \  \
    //  \ \  \    \ \   __  \ \   __  \ \  \ \  \\ \  \
    //   \ \  \____\ \  \ \  \ \  \ \  \ \  \ \  \\ \  \
    //    \ \_______\ \__\ \__\ \__\ \__\ \__\ \__\\ \__\
    //     \|_______|\|__|\|__|\|__|\|__|\|__|\|__| \|__|
    //
    var resultArray: AnyObject[] = []
    init(array: AnyObject[]) {
        self.resultArray = array
    }

    func first() -> AnyObject? {
        return $.first(self.resultArray)
    }
    
    func flatten() -> $ {
        self.resultArray = $.flatten(self.resultArray)
        return self
    }
    
    func initial() -> $ {
        return self.initial(1)
    }
    
    func initial(numElements: Int) -> $ {
        self.resultArray = $.initial(self.resultArray, numElements: numElements)
        return self
    }
    
    func map(function: (AnyObject) -> AnyObject) -> $ {
        var result: AnyObject[] = []
        for elem : AnyObject in self.resultArray {
            result += function(elem)
        }
        self.resultArray = result
        return self
    }
    
    func each(function: (AnyObject) -> ()) -> $ {
        for elem : AnyObject in self.resultArray {
            function(elem)
        }
        return self
    }
    
    func filter(function: (AnyObject) -> Bool) -> $ {
        var result: AnyObject[] = []
        for elem : AnyObject in self.resultArray {
            if function(elem) {
                result += elem
            }
        }
        self.resultArray = result
        return self
    }
    
    func all(function: (AnyObject) -> Bool) -> Bool {
        for elem : AnyObject in self.resultArray {
            if !function(elem) {
                return false
            }
        }
        return true
    }
    <commit_msg>Adding each and map overloaded functions with index<commit_after>//
//    ___    ___       __   ___  ________ _________
//  _|\  \__|\  \     |\  \|\  \|\  _____\\___   ___\
// |\   ____\ \  \    \ \  \ \  \ \  \__/\|___ \  \_|
// \ \  \___|\ \  \  __\ \  \ \  \ \   __\    \ \  \
//  \ \_____  \ \  \|\__\_\  \ \  \ \  \_|     \ \  \
//   \|____|\  \ \____________\ \__\ \__\       \ \__\
//     ____\_\  \|____________|\|__|\|__|        \|__|
//    |\___    __\
//    \|___|\__\_|
//         \|__|
//
//  $.swift
//  Dollar - A functional tool-belt for Swift Language
//
//  Created by <NAME> on 6/3/14.
//  Copyright (c) 2014 Encore Dev Labs LLC. All rights reserved.
//

import Foundation

class $ {
    
    //  ________  ___  ___  ________  ___  ________
    // |\   ____\|\  \|\  \|\   __  \|\  \|\   ___  \
    // \ \  \___|\ \  \\\  \ \  \|\  \ \  \ \  \\ \  \
    //  \ \  \    \ \   __  \ \   __  \ \  \ \  \\ \  \
    //   \ \  \____\ \  \ \  \ \  \ \  \ \  \ \  \\ \  \
    //    \ \_______\ \__\ \__\ \__\ \__\ \__\ \__\\ \__\
    //     \|_______|\|__|\|__|\|__|\|__|\|__|\|__| \|__|
    //
    var resultArray: AnyObject[] = []
    init(array: AnyObject[]) {
        self.resultArray = array
    }

    func first() -> AnyObject? {
        return $.first(self.resultArray)
    }
    
    func flatten() -> $ {
        self.resultArray = $.flatten(self.resultArray)
        return self
    }
    
    func initial() -> $ {
        return self.initial(1)
    }
    
    func initial(numElements: Int) -> $ {
        self.resultArray = $.initial(self.resultArray, numElements: numElements)
        return self
    }
    
    func map(function: (AnyObject) -> AnyObject) -> $ {
        var result: AnyObject[] = []
        for elem : AnyObject in self.resultArray {
            result += function(elem)
        }
        self.resultArray = result
        return self
    }
    
    func map(function: (Int, AnyObject) -> AnyObject) -> $ {
        var result: AnyObject[] = []
        for (index, elem : AnyObject) in enumerate(self.resultArray) {
            result += function(index, elem)
        }
        self.resultArray = result
        return self
    }
    
    func each(function: (AnyObject) -> ()) -> $ {
        for elem : AnyObject in self.resultArray {
            function(elem)
        }
        return self
    }
    
    func each(function: (Int, AnyObject) -> ()) -> $ {
        for (index, elem : AnyObject) in enumerate(self.resultArray) {
            function(index, elem)
        }
        return self
    }
    
    func filter(function: (AnyObject) -> Bool) -> $ {
        var result: AnyObject[] = []
        for elem : AnyObject in self.resultArray {
            if function(elem) {
                result += elem
            }
        }
        self.resultArray = result
        return self
    }
    
    func all(function: (AnyObject) -> Bool) -> Bool {
        for elem : AnyObject in self.resultArray {
            if !function(elem) {
                return false
            }
        }
        return true
    }
    
{'fraction_non_alphanumeric': 0.17610287551348455, 'fraction_numerical': 0.003214859796392213, 'mean_word_length': 1.128468263017864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3174308', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1865, 'n_words': 288}