Kotlin interpreter for Apache Zeppelin

Overview

Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference. It is designed to interoperate fully with Java, and the JVM version of its standard library depends on the Java Class Library, but type inference allows its syntax to be more concise.

Configuration

Name Default Description
zeppelin.kotlin.maxResult 1000 Max n
zeppelin.kotlin.shortenTypes true Display shortened types instead of full, e.g. Int vs kotlin.Int

Example

%kotlin 

fun square(n: Int): Int = n * n

Kotlin Context

Kotlin context is accessible via kc object bound to the interpreter. It holds vars and functions fields that return all user-defined variables and functions present in the interpreter. You can also print variables or functions by calling kc.showVars() or kc.showFunctions().

Example

fun square(n: Int): Int = n * n

val greeter = { s: String -> println("Hello $s!") }
val l = listOf("Drive", "to", "develop")

kc.showVars()
kc.showFunctions()

Output: l: List<String> = [Drive, to, develop] greeter: (String) -> Unit = (kotlin.String) -> kotlin.Unit fun square(Int): Int