This file contains 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
@Test | |
public void removeSpacesFromTheString() { | |
ReversePolishNotation rpn = new ReversePolishNotation(); | |
String[] result = rpn.getStringArray("3 4 +"); | |
assertEquals("3", result[0]); | |
assertEquals("4", result[1]); | |
assertEquals("+", result[2]); | |
} |
This file contains 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 java.util.* | |
fun main() { | |
println(evaluate("4 2 /")) | |
} | |
fun evaluate(expr: String): Float { | |
val chars = expr.split(" ") | |
val stack = Stack<Float>() | |
val operator = operationForOperator() |
This file contains 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 java.util.HashMap; | |
import java.util.Stack; | |
import java.util.function.BiFunction; | |
class ReversePolishNotation { | |
public static void main(String[] args) { | |
System.out.println(evaluate("4 2 /")); | |
} |
This file contains 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 java.util.Stack; | |
import java.util.function.BiFunction; | |
class ReversePolishNotation { | |
public static void main(String[] args) { | |
System.out.println(evaluate("4 2 /")); | |
} | |
public static double evaluate(String expr) { |
This file contains 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 java.util.Stack; | |
class ReversePolishNotation { | |
public static void main(String[] args) { | |
System.out.println(evaluate("5 1 2 + 4 * + 3 -")); | |
} | |
public static double evaluate(String expr) { | |
String[] digitString = expr.split(" "); |
This file contains 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
from graphene import ObjectType, Stringclass ExampleQuery(ObjectType): | |
hello = String() | |
def resolve_hello(self, info): | |
return "Hello" | |
class RootQuery(ExampleQuery, ObjectType): | |
pass | |
schema = Schema(query=RootQuery) |
This file contains 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
from flask_graphql import GraphQLView | |
def create_app(): | |
... from app.schema import schema app.add_url_rule( | |
'/graphql', | |
view_func=GraphQLView.as_view( | |
'graphql', | |
schema=schema, | |
graphiql=True # for having the GraphiQL interface | |
) | |
) |
This file contains 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
query getFriends { | |
user { | |
friends { | |
...friendFields | |
} | |
mutualFriends { | |
...friendFields | |
} | |
} | |
} |
This file contains 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
union SearchResult = User | Company | |
type User { | |
name: String | |
age: Int | |
} | |
type Company { | |
name: String | |
address: Int |
This file contains 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
interface Profile { | |
id: ID | |
name: String | |
} | |
type User implements Profile { | |
id: ID | |
name: String | |
age: Int | |
} |