<commit_before>//
//  AudioKitHelpers.swift
//  AudioKit
//
//  Created by <NAME>, revision history on Github.
//  Copyright © 2016 AudioKit. All rights reserved.
//

import Foundation
import CoreAudio
import AudioToolbox

public typealias MIDINoteNumber = Int
public typealias MIDIVelocity = Int
public typealias MIDIChannel = Int


extension Collection where IndexDistance == Int {
    /// Return a random element from the collection
    public func randomElement() -> Iterator.Element {
        let offset = Int(arc4random_uniform(UInt32(count.toIntMax())))
        return self[index(startIndex, offsetBy: offset)]
    }
}

/// Helper function to convert codes for Audio Units
/// - parameter string: Four character string to convert
///
public func fourCC(_ string: String) -> UInt32 {
    let utf8 = string.utf8
    precondition(utf8.count == 4, "Must be a 4 char string")<commit_msg>* readied unintentionally removed refactor of random element selection<commit_after>//
//  AudioKitHelpers.swift
//  AudioKit
//
//  Created by <NAME>, revision history on Github.
//  Copyright © 2016 AudioKit. All rights reserved.
//

import Foundation
import CoreAudio
import AudioToolbox

public typealias MIDINoteNumber = Int
public typealias MIDIVelocity = Int
public typealias MIDIChannel = Int


extension Collection where IndexDistance == Int {
    /// Return a random element from the collection
    public var randomIndex: Index {
        let offset = Int(arc4random_uniform(UInt32(count.toIntMax())))
        return index(startIndex, offsetBy: offset)
    }

    public func randomElement() -> Iterator.Element {
        return self[randomIndex]
    }
}

/// Helper function to convert codes for Audio Units
/// - parameter string: Four character string to convert
///
public func fourCC(_ string: String) -> UInt32 {
    let utf8 = string.utf8
    precondition(utf8.count == 4, "Must be a 4 char string")
{'fraction_non_alphanumeric': 0.09133858267716535, 'fraction_numerical': 0.014698162729658792, 'mean_word_length': 3.4741784037558685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4034685', 'n_tokens_mistral': 545, 'n_tokens_neox': 516, 'n_words': 193}