             return ([element], remainder1)
         }
     }
-    return parser
 }
 
 private func between<A, B, C>(_ a: @escaping Parser<A>, _ b: @escaping Parser<B>, _ c: @escaping Parser<C>) -> Parser<B> {
-    let parser: Parser<B> = { stream in
+    return { stream in
         guard let (_, remainder1) = a(stream) else { return nil }
         guard let (result2, remainder2) = b(remainder1) else { return nil }
         guard let (_, remainder3) = c(remainder2) else { return nil }
         return (result2, remainder3)
     }
-    return parser
 }
 
 private func and<A, B>(_ left: @escaping Parser<A>, _ right: @escaping Parser<B>) -> Parser<(A, B)> {

private typealias Parser<A> = (Stream) -> (A, Stream)?

private func map<A, B>(_ parser: @escaping Parser<A>, _ transform: @escaping (A) -> B) -> Parser<B> {
    let newParser: Parser<B> = { stream in
        guard let (result, remainder) = parser(stream) else { return nil }
        return (transform(result), remainder)
    }
    return newParser
}

private func or<A>(_ leftParser: @escaping Parser<A>, _ rightParser: @escaping Parser<A>) -> Parser<A> {
    let parser: Parser<A> = { stream in
        return leftParser(stream) ?? rightParser(stream)
    }
    return parser
}

private func one<A>(of parsers: [Parser<A>]) -> Parser<A> {
    let parser: Parser<A> = { stream in
        for parser in parsers {
            if let x = parser(stream) {
                return x

}

private func character(_ character: Character) -> Parser<Character> {
    return { stream in
        guard let firstCharacter = stream.first, firstCharacter == character else { return nil }
        return (firstCharacter, stream.dropFirst())
    }
}

private func word(_ string: String) -> Parser<String> {
    let parsers = string.characters.map({ character($0) })
    return { stream in
        var characters: [Character] = []
        var remainder = stream
        for parser in parsers {
