{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def a = 1 //local variable\n", "b = 2 //global variable" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a //error" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "b //this works" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "//closure example\n", "timesTwo = {x -> x*2}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timesTwo(4)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timesTwo(\"Multiplying Strings!\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sin(3.1415)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import java.nio.charset.Charset;\n", "\n", "byte[] cp1251Bytes = new byte[3];\n", "cp1251Bytes[0] = (byte) 0xFD;\n", "cp1251Bytes[1] = (byte) 0xFE;\n", "cp1251Bytes[2] = (byte) 0xFF;\n", "\n", "byte[] utfBytes = new byte[6];\n", "utfBytes[0] = (byte) 0xD1;\n", "utfBytes[1] = (byte) 0x8D;\n", "utfBytes[2] = (byte) 0xD1;\n", "utfBytes[3] = (byte) 0x8E;\n", "utfBytes[4] = (byte) 0xD1;\n", "utfBytes[5] = (byte) 0x8F;\n", "\n", "String cp1251Str = new String(cp1251Bytes, Charset.forName(\"CP1251\"));\n", "byte[] utfBb = cp1251Str.getBytes(Charset.forName(\"UTF-8\"));\n", "for(byte b: utfBb){\n", " System.out.print((String.format(\"%x\", b)));\n", "}\n", "\n", "new Plot(\n", " title: new String(cp1251Bytes, Charset.forName(\"CP1251\")), \n", " xLabel: new String(utfBb, Charset.forName(\"UTF-8\")), \n", " yLabel: new String(utfBytes, Charset.forName(\"UTF-8\")))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "tg1" ] }, "outputs": [], "source": [ "3 + 2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "beakerx.getCodeCells('tg1')[0].outputs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "celltoolbar": "Tags", "kernelspec": { "display_name": "Groovy", "language": "groovy", "name": "groovy" }, "language_info": { "codemirror_mode": "groovy", "file_extension": ".groovy", "mimetype": "", "name": "Groovy", "nbconverter_exporter": "", "version": "2.4.3" } }, "nbformat": 4, "nbformat_minor": 1 }