- Proposal: TBD
- Author: Charlotte Tortorella
- Editor: Soroush Khanlou
- Review Manager: TBD
- Status: TBD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum Zone { | |
indirect case node(component: String, leaves: [Zone]) | |
case leaf(component: String, path: String) | |
} | |
func recurseCreateZones(path: [String], separated: [String], root: Zone) -> Zone { | |
guard case .node(let component, let leaves) = root else { fatalError() } | |
switch (separated.first, separated.count) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(*!) :: (Ord a, Num a) => a -> a -> a | |
(*!) a b = | |
let | |
multiply _ 0 t = t | |
multiply a b t = multiply a (b - 1) (t + a) | |
in | |
if b >= 0 | |
then multiply a b 0 | |
else negate $ multiply a (negate b) 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#Convert a video into chunks of a given size | |
chunk = ARGV.shift.to_f | |
file = ARGV.shift | |
extension = File.extname(file) | |
basename = File.join(File.dirname(file), File.basename(file, extension)) | |
durations = `ffmpeg -i '#{file}' 2>&1`.match(/Duration: ([\d:.]*)/).captures.first.split(':') | |
seconds = durations[0].to_f * 3600 + durations[1].to_f * 60 + durations[2].to_f | |
n_chunks = (seconds / chunk).ceil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.String.Utils | |
import Data.List | |
import Data.Char | |
import Data.Maybe | |
import System.Environment | |
main :: IO () | |
main = do | |
strings <- getArgs | |
mapM_ (putStrLn . pronounify) strings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
@IBOutlet weak var nameTextField: UITextField! | |
@IBOutlet weak var passwordTextField: UITextField! | |
func nameValidation(for field: UITextField) -> Signal<Bool, NoError> { | |
return field | |
.reactive | |
.continuousTextValues | |
.skipNil() | |
.map { $0.characters.count > 3 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Monoid.swift | |
// FPExamples | |
// | |
// Created by Charlotte Tortorella on 28/11/16. | |
// Copyright © 2016 Charlotte Tortorella. All rights reserved. | |
// | |
import Foundation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precedencegroup ForwardApplicationPrecedence { | |
associativity: left | |
} | |
/// Applies `f` to `arg`. | |
infix operator |> : ForwardApplicationPrecedence | |
func |> <T, U>(arg: T, f: (T) -> U) -> U { | |
return f(arg) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactiveCocoa | |
import ReSwift | |
import Result | |
class ObservableStore<State: StateType>: Store<State> { | |
internal let observable: MutableProperty<State> | |
var producer: SignalProducer<State, NoError> { | |
get { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Device: Decodable { | |
static func decode(json: AnyObject) throws -> Device { | |
guard let resolvedTypes = try json => "devices" as? NSArray else { | |
throw NSArraySucks.ItReallySucks | |
} | |
let types = try (resolvedTypes as [AnyObject]).map { | |
try decodeAsOneOf($0, objectTypes: MSensorType.self, ColourType.self, LEDType.self, GenericType.self) | |
}.flatMap { |