<commit_before>//: Closures

func printString(aString: String) {
  println("Printing the passed string: \(aString)")
}

printString("Hi, my lovely")

let someFunction = printString

someFunction("Hiya")

//func printInt(number: Int) {
//  println("\(number)")
//}
//
//let numberOfApples = 3
//
//printInt(numberOfApples)

<commit_msg>Closures, continued.<commit_after>//: Closures

func printString(aString: String) {
  println("Printing the passed string: \(aString)")
}

printString("Hi, my lovely")

let someFunction = printString

someFunction("Hiya")

//func printInt(number: Int) {
//  println("\(number)")
//}
//
//let numberOfApples = 3
//
//printInt(numberOfApples)

func displayString(printStringFunc: (String) -> Void) {
  printStringFunc("I'm a function inside another function")
}

displayString(printString)

let allNumbers = [1,2,3,4,5,6,7,8,9,10]

func isEvenNumber(number: Int) -> Bool {
  return number % 2 == 0
}

isEvenNumber(-9000)

let ifEven = isEvenNumber
let evenNumbers = allNumbers.filter(ifEven)

// own

let someString = ["Makka", "Mokko", "Adelaide", "Omnicomni", "Marconi", "Serpent", "Zucchini", "Pasta", "Dolci", "Aurum", "Persistence"]

func containsMagicString(haystack: String) -> Bool {
  return contains(haystack, "a")
}

let getMagic = containsMagicString

let magicWords = someString.filter(getMagic)

// let getDynaMagic = contains
// let dynaMagicWords = someString.filter(<#includeElement: String -> Bool##String -> Bool#>)

// Returning Functions


func printerFunction() -> (Int) -> () {
  func printInteger(number: Int) {
    println("The integer passed in is: \(number)")
  }
  return printInteger
}

let printAndReturnIntegerFunc = printerFunction()

printAndReturnIntegerFunc(2)






{'fraction_non_alphanumeric': 0.15570934256055363, 'fraction_numerical': 0.011534025374855825, 'mean_word_length': 4.783333333333333, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, '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': '9385', 'n_tokens_mistral': 627, 'n_tokens_neox': 583, 'n_words': 136}