Skip to content

10 new Swift 4 updates #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Linear Search/LinearSearch.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 4.0b4
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
Expand Down
9 changes: 8 additions & 1 deletion Minimum Edit Distance/MinimumEditDistance.playground/Contents.swift
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Minimum Edit Distance

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

extension String {

public func minimumEditDistance(other: String) -> Int {
Expand Down Expand Up @@ -25,7 +32,7 @@ extension String {
} else {
// minimum of the cost of insertion, deletion, or substitution
// added to the already computed costs in the corresponding cells
matrix[i + 1][j + 1] = min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
matrix[i + 1][j + 1] = Swift.min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
}
}
}
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion Minimum Edit Distance/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ for (i, selfChar) in self.characters.enumerated() {
} else {
// minimum of the cost of insertion, deletion, or substitution
// added to the already computed costs in the corresponding cells
matrix[i + 1][j + 1] = min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
matrix[i + 1][j + 1] = Swift.min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion Monty Hall Problem/MontyHall.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

import Foundation

func random(_ n: Int) -> Int {
Expand Down Expand Up @@ -43,7 +48,7 @@ func playRound() {
}

// Run the simulation a large number of times.
for i in 1...5000 {
for _ in 1...5000 {
playRound()
}

Expand Down
5 changes: 5 additions & 0 deletions Naive Bayes Classifier/NaiveBayes.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import Foundation

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

/*:
## Naive Bayes Classifier

Expand Down
5 changes: 5 additions & 0 deletions Rabin-Karp/Rabin-Karp.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//: Taking our rabin-karp algorithm for a walk

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

import UIKit

struct Constants {
Expand Down
7 changes: 7 additions & 0 deletions Radix Tree/RadixTree.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Radix Tree

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

var radix = RadixTree()
var radixWiki = RadixTree()

Expand Down
5 changes: 5 additions & 0 deletions Ring Buffer/RingBuffer.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

public struct RingBuffer<T> {
fileprivate var array: [T?]
fileprivate var readIndex = 0
Expand Down
5 changes: 5 additions & 0 deletions Run-Length Encoding/RLE.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

import Foundation

let originalString = "aaaaabbbcdeeeeeeef"
Expand Down
6 changes: 0 additions & 6 deletions Run-Length Encoding/RLE.playground/timeline.xctimeline

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

import Foundation

/* Returns a random integer in the range min...max, inclusive. */
Expand Down
7 changes: 7 additions & 0 deletions Set Cover (Unweighted)/SetCover.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// SetCover

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

let universe1 = Set(1...7)
let array1 = randomArrayOfSets(covering: universe1)
let cover1 = universe1.cover(within: array1)
Expand Down