def a = 1 //local variable
b = 2 //global variable
2
a //error
groovy.lang.MissingPropertyException: No such property: a for class: script1513885590590911287145 at script1513885590590911287145.run(script1513885590590911287145.groovy:1) at com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.run(GroovyCodeRunner.java:71)
b //this works
2
//closure example
timesTwo = {x -> x*2}
script1513885591155231881823$_run_closure1@68beeb7c
timesTwo(4)
8
timesTwo("Multiplying Strings!")
Multiplying Strings!Multiplying Strings!
sin(3.1415)
9.265358966049026E-5
import java.nio.charset.Charset;
byte[] cp1251Bytes = new byte[3];
cp1251Bytes[0] = (byte) 0xFD;
cp1251Bytes[1] = (byte) 0xFE;
cp1251Bytes[2] = (byte) 0xFF;
byte[] utfBytes = new byte[6];
utfBytes[0] = (byte) 0xD1;
utfBytes[1] = (byte) 0x8D;
utfBytes[2] = (byte) 0xD1;
utfBytes[3] = (byte) 0x8E;
utfBytes[4] = (byte) 0xD1;
utfBytes[5] = (byte) 0x8F;
String cp1251Str = new String(cp1251Bytes, Charset.forName("CP1251"));
byte[] utfBb = cp1251Str.getBytes(Charset.forName("UTF-8"));
for(byte b: utfBb){
System.out.print((String.format("%x", b)));
}
new Plot(
title: new String(cp1251Bytes, Charset.forName("CP1251")),
xLabel: new String(utfBb, Charset.forName("UTF-8")),
yLabel: new String(utfBytes, Charset.forName("UTF-8")))
d18dd18ed18f
3 + 2
5
beakerx.getCodeCells('tg1')[0].outputs