{ "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": [ "// cell10\n", "beakerx.getCodeCells('tg1')[0].outputs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "// cell10 expected result\n", "Image(\"../../resources/img/groovy/groovy/cell10_case1.png\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "// cell11\n", "lst = []\n", "lst << ['hours':10]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "// cell11 expected result\n", "Image(\"../../resources/img/groovy/groovy/cell11_case1.png\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "// cell12\n", "[a: null, b:1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "// cell12 expected result\n", "Image(\"../../resources/img/groovy/groovy/cell12_case1.png\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%python\n", "from beakerx import *\n", "pp = Plot(title=\"Title\", xLabel=\"Horizontal\", yLabel=\"Vertical\")\n", "pp.add(Line(displayName=\"Line\", x=[1, 4, 6, 8, 10],y=[3, 6, 4, 5, 9]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "press 'Tab' for autocomplete" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "press 'Shift' + 'Tab' for doc" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "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 }