<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Polyglot Magics\n",
    "\n",
    "The BeakerX kernels have magics to run other kernels, including `%%python`.  There are magics for each BeakerX langage: `%%groovy`, `%%java`, `%%scala`, `%%sql`, `%%clojure`, and `%%kotlin`.  There is also a `%%kernel` magic to access any kernel available to Jupyter.  Widgets work through these magics.\n",
    "\n",
    "## Python Magic\n",
    "\n",
    "For example, even though this is a Groovy notebook, you can run Python code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "print(\"regular\")\n",
    "{\"output\": \"works\"}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Widgets Work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "import ipywidgets as widgets\n",
    "w = widgets.IntSlider()\n",
    "w"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "w.value"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scala Table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%scala\n",
    "new TableDisplay(Seq(Map(\"a\" -> 1, \"b\" -> 2, \"c\" -> 3),\n",
    "                     Map(\"a\" -> 4, \"b\" -> 5, \"c\" -> 6),\n",
    "                     Map(\"a\" -> 7, \"b\" -> 8, \"c\" -> 8)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Kernel Magic\n",
    "\n",
    "Access any kernel available to Jupyter by name:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%kernel julia-0.6\n",
    "(1 + 1im) * (1 - 1im)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Groovy",
   "language": "groovy",
   "name": "groovy"
  },
  "language_info": {<commit_msg>add R example to polyglot magic doc<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Polyglot Magics\n",
    "\n",
    "The BeakerX kernels have magics to run other kernels, including `%%python`.  There are magics for each BeakerX langage: `%%groovy`, `%%java`, `%%scala`, `%%sql`, `%%clojure`, and `%%kotlin`.  There is also a `%%kernel` magic to access any kernel available to Jupyter.  Widgets work through these magics.\n",
    "\n",
    "## Python Magic\n",
    "\n",
    "For example, even though this is a Groovy notebook, you can run Python code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "print(\"regular\")\n",
    "{\"output\": \"works\"}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Widgets Work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "import ipywidgets as widgets\n",
    "w = widgets.IntSlider()\n",
    "w"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "w.value"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scala Table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%scala\n",
    "new TableDisplay(Seq(Map(\"a\" -> 1, \"b\" -> 2, \"c\" -> 3),\n",
    "                     Map(\"a\" -> 4, \"b\" -> 5, \"c\" -> 6),\n",
    "                     Map(\"a\" -> 7, \"b\" -> 8, \"c\" -> 8)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Kernel Magic\n",
    "\n",
    "Access any kernel available to Jupyter by name:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%kernel ir\n",
    "x <- rnorm(1000)\n",
    "plot(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%kernel julia-0.6\n",
    "(1 + 1im) * (1 - 1im)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Groovy",
   "language": "groovy",
   "name": "groovy"
  },
  "language_info": {
{'fraction_non_alphanumeric': 0.24366600572813396, 'fraction_numerical': 0.00749063670411985, 'mean_word_length': 2.287472845763939, 'pattern_counts': {'":': 95, '<': 4, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '99596', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1736, 'n_words': 380}