Skip to content

Instantly share code, notes, and snippets.

@a-dminator
Created October 25, 2017 07:33
Show Gist options
  • Save a-dminator/5dae265629abf3a469aaca7d9ba5510b to your computer and use it in GitHub Desktop.
Save a-dminator/5dae265629abf3a469aaca7d9ba5510b to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
val a = args[0].toDouble()
val b = args[1].toDouble()
val c = args[2].toDouble()
val r = println(x1(a, b, c))
println(r)
}
// fun run(action: () -> Any): Any = <...>
fun x1(a: Double, b: Double, c: Double): Unit = run({
val d = b*b - 4*a*c
((-b + Math.sqrt(d)) / 2*a).toFloat()
})
fun x2(a: Double, b: Double, c: Double) = run({
val d = b*b - 4*a*c
(-b - Math.sqrt(d)) / 2*a
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment