The scijava-jupyter-kernel
is polyglot which means you can use multiple languages in the same notebook. Available languages are :
All those script languages are executed by the Scijava Scripting Mechanism. It means that any languages added to Scijava Script will work on scijava-jupyter-kernel
.
You can specify a language per cell with the following shebang-like syntax : #!groovy
. It needs to be on the first line of the cell. If nothing is specified, Groovy is the default language or the last selected language is used.
Now let's see some of the specific feature of the scripting languages.
#!groovy
println "The Groovy version is " + GroovySystem.version
The Groovy version is 2.4.10
No Outputs
class HelloWorld {
def greet( name ){
"Hello ${name}!"
}
}
def hm = new HelloWorld()
println hm.greet("Groovy")
Hello Groovy!
No Outputs
def pickEven(n, block) {
for (int i=2; i <= n; i += 2) {
block(i)
}
}
pickEven(10) {
println it
}
2 4 6 8 10
No Outputs
#!python
import sys
print(sys.version)
2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)]
No Outputs
# Code is from http://introtopython.org/classes.html
class Rocket(object):
# Rocket simulates a rocket ship for a game,
# or a physics simulation.
def __init__(self):
# Each rocket has an (x,y) position.
self.x = 0
self.y = 0
def move_up(self):
# Increment the y-position of the rocket.
self.y += 1
# Create a fleet of 5 rockets, and store them in a list.
my_rockets = [Rocket() for x in range(0,5)]
# Move the first rocket up.
my_rockets[0].move_up()
# Show that only the first rocket has moved.
for rocket in my_rockets:
print("Rocket altitude:", rocket.y)
('Rocket altitude:', 1) ('Rocket altitude:', 0) ('Rocket altitude:', 0) ('Rocket altitude:', 0) ('Rocket altitude:', 0)
No Outputs
printBanner();
Hashtable hashtable = new Hashtable(); Date date = new Date(); hashtable.put( "today", date );
// Print the current clock value print( System.currentTimeMillis() );
// Loop for (int i=0; i<5; i++) print(i);
#!clojure
(println *clojure-version*)
{:major 1, :minor 8, :incremental 0, :qualifier nil}
No Outputs
(let [fn-list [+ - * /]]
(println ((apply juxt fn-list) 1 2)))
[3 -1 2 1/2]
No Outputs
#!javascript
print("Hello World :-)");
Hello World :-)
No Outputs
time = 18
if (time < 10) {
greeting = "Good morning";
} else if (time < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
print(greeting)
Good day
No Outputs
var cars = ["BMW", "Volvo", "Saab", "Ford"];
var text = "";
for (var i = 0; i < cars.length; i++) {
text += cars[i] + "\n";
}
print(text);
BMW Volvo Saab Ford
No Outputs
#!scala
scala.util.Properties.versionMsg
Scala library version 2.12.1 -- Copyright 2002-2016, LAMP/EPFL and Lightbend, Inc.
class Point(val xc: Int, val yc: Int) {
var x: Int = xc
var y: Int = yc
def move(dx: Int, dy: Int) {
x = x + dx
y = y + dy
println("Point x location : " + x);
println("Point y location : " + y);
}
}
val pt = new Point(10, 20);
// Move to a new location
pt.move(10, 10);
No Outputs