<commit_before>//
//  Optional+Extension.swift
//  MyLibrary
//
//  Created by <NAME> on 8/1/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

public func map<T1, T2>(_ transform: @escaping (T1) -> T2) -> (T1?) -> T2? {
    return { s1 in
        return s1.map(transform)
    }
}

extension Optional {
    
    public func apply<U>(_ f: ((Wrapped) -> U)?) -> U? {
        switch f {
        case .some(let someF):
            return map(someF)
        case .none:
            return .none
        }
    }
    
}<commit_msg>Add missing functions to Optional extension.<commit_after>//
//  Optional+Extension.swift
//  MyLibrary
//
//  Created by <NAME> on 8/1/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

public func map<T1, T2>(_ transform: @escaping (T1) -> T2) -> (T1?) -> T2? {
    return { $0.map(transform) }
}

extension Optional {
    
    public func apply<U>(_ transform: ((Wrapped) -> U)?) -> U? {
        switch transform {
        case .some(let someTransform):
            return map(someTransform)
        case .none:
            return .none
        }
    }
    
}

public func apply<T, U>(_ transform: ((T) -> U)?) -> (T?) -> U? {
    return { $0.apply(transform) }
}
{'fraction_non_alphanumeric': 0.1669435215946844, 'fraction_numerical': 0.026578073089700997, 'mean_word_length': 1.9462102689486553, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 25, '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': '3867756', 'n_tokens_mistral': 428, 'n_tokens_neox': 410, 'n_words': 113}