<commit_before>//
//  ExSwift.swift
//  ExSwift
//
//  Created by pNre on 07/06/14.
//  Copyright (c) 2014 pNre. All rights reserved.
//

import Foundation

infix operator =~ {}
infix operator |~ {}
infix operator .. {}
infix operator <=> {}

public typealias Ex = ExSwift

public class ExSwift {
    
    /**
        Creates a wrapper that, executes function only after being called n times.
    
        - parameter n: No. of times the wrapper has to be called before function is invoked
        - parameter function: Function to wrap
        - returns: Wrapper function
    */
    public class func after <P, T> (_ n: Int, function: (P...) -> T) -> ((P...) -> T?) {
        
        typealias Function = ([P]) -> T
    
        var times = n
        
        return {
            (params: P...) -> T? in
            
            //  Workaround for the now illegal (T...) type.
            let adaptedFunction = unsafeBitCast(function, to: Function.self)
            times -= 1
            if times <= 0 {
                return adaptedFunction(params)
            }
            
            return nil<commit_msg>Xcode 8b6: `operator`s should no longer be declared with body<commit_after>//
//  ExSwift.swift
//  ExSwift
//
//  Created by pNre on 07/06/14.
//  Copyright (c) 2014 pNre. All rights reserved.
//

import Foundation

infix operator =~
infix operator |~
infix operator ..
infix operator <=>

public typealias Ex = ExSwift

public class ExSwift {
    
    /**
        Creates a wrapper that, executes function only after being called n times.
    
        - parameter n: No. of times the wrapper has to be called before function is invoked
        - parameter function: Function to wrap
        - returns: Wrapper function
    */
    public class func after <P, T> (_ n: Int, function: (P...) -> T) -> ((P...) -> T?) {
        
        typealias Function = ([P]) -> T
    
        var times = n
        
        return {
            (params: P...) -> T? in
            
            //  Workaround for the now illegal (T...) type.
            let adaptedFunction = unsafeBitCast(function, to: Function.self)
            times -= 1
            if times <= 0 {
                return adaptedFunction(params)
            }
            
            return nil
{'fraction_non_alphanumeric': 0.10890652557319223, 'fraction_numerical': 0.01146384479717813, 'mean_word_length': 1.5842824601366743, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2602141', 'n_tokens_mistral': 652, 'n_tokens_neox': 616, 'n_words': 234}