View Neuron.swift
//: Playground - noun: a place where people can play | |
import Foundation | |
protocol Neuron { | |
var weights: [Double] {get} | |
func feedforward(input: [Double]) -> Double | |
func activation(input: Double) -> Double | |
} |
View Observable.swift
protocol Disposable { | |
func dispose() | |
func addToDisposablesBag(bag: DisposablesBag) | |
} | |
extension Disposable { | |
func addToDisposablesBag(bag: DisposablesBag) { | |
bag.add(self) | |
} | |
} |
View Promises_futures_experiments.swift
// | |
// Promise.swift | |
// PiGuardMobile | |
// | |
// Created by Stefano Vettor on 06/04/16. | |
// Copyright © 2016 Stefano Vettor. All rights reserved. | |
// | |
import Foundation |
View String+Enhancement.swift
import Foundation | |
extension String { | |
func substringWithRange(r: Range<Int>) -> String { | |
return substringWithRange(Range(start: startIndex.advancedBy(r.startIndex), end: startIndex.advancedBy(r.endIndex))) | |
} | |
func substringToIndex(i: Int) -> String { | |
return substringToIndex(startIndex.advancedBy(i)) |
View Protocols_and_trees.swift
protocol HasName { | |
var name: String { get } | |
} | |
protocol HasSubNodes: HasName { | |
var subNodes: [HasName] { get } | |
} | |
protocol HasData: HasName { |