Skip to content

Instantly share code, notes, and snippets.

View stefc's full-sized avatar

Stefan B\u+00F6ther stefc

  • Dataport A.d.ö.R.
  • Schleswig-Holstein, Germany, Europe, Earth, Milkyway
View GitHub Profile
@stefc
stefc / .gitignore
Last active January 4, 2018 07:28
Swift Package Manager Samples
.DS_Store
/.build
/Packages
/*.xcodeproj
Package.resolved
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/*_Info.plist
@stefc
stefc / Package.swift
Created January 4, 2018 07:34
The initially by the Swift-Package Manager generated Project Structure of xProcs
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "xProcs",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
@stefc
stefc / IntTests.swift
Created January 4, 2018 08:06
Unit Test for IntPow functions
import XCTest
import xProcs
class IntTests: XCTestCase {
func testIntPow() {
XCTAssertEqual(IntPow(5, exp: 2), 25)
XCTAssertEqual(IntPow(5, exp: 1), 5)
XCTAssertEqual(IntPow(5, exp: 0), 1)
}
import Foundation
public func IntPow(_ base: Int, exp: Int) -> Int {
guard exp >= 0 else {
return 0
}
guard exp > 0 else {
return 1
}
return (1..<exp).reduce(base) { (accu, _) in accu * abs(base) }