Giter Club home page Giter Club logo

iracket's Introduction

IRacket

IRacket is a Racket kernel for IPython/Jupyter. IRacket enables interactive notebook-style programming with Racket. This package also includes Racket bindings for the C3.js charting library.

This package includes a number of sample notebooks that demonstrate IRacket and the Gamble probabilistic programming language.

Installation

Requirements

Installation steps

  1. Clone this repository.
  2. Run the installation.sh script from the current directory.
./installation.sh

If you previously installed IRacket, answer "n" when it asks about installing C3 integration. Otherwise say "y" or hit enter.

Manual installation instructions

  1. Clone this repository.
  2. Run the following from the root of this repository
mkdir -p $(ipython locate)/kernels/racket/
cp ./static/kernel.json $(ipython locate)/kernels/racket/kernel.json
  1. Adjust the copied kernel.json to refer to iracket in the path of this repository in place of IRACKET_SRC_DIR.
  2. If racket isn't on your path, adjust the copied kernel.json to refer to the absolute path of racket.

C3 Integration (Charts)

Note that the front-end integration for C3 will eventually be moved into its own repository.

If you use a non-default profile, set IPYTHON_PROFILE to the name of that profile, then run the following:

IPYTHON_PROFILE=
IPYTHON_PROFILE_STATIC=$(ipython locate profile $IPYTHON_PROFILE)/static
cp ./static/ic3.js $(ipython locate)/nbextensions/ic3.js
cat ./static/custom.js >> $IPYTHON_PROFILE_STATIC/custom/custom.js
curl -L https://github.com/mbostock/d3/raw/v3.5.5/d3.min.js \
    > $IPYTHON_PROFILE_STATIC/d3.js
curl -L https://github.com/masayuki0812/c3/raw/0.4.10/c3.min.js \
    > $IPYTHON_PROFILE_STATIC/c3.js
curl -L https://github.com/masayuki0812/c3/raw/0.4.10/c3.min.css \
    > $IPYTHON_PROFILE_STATIC/c3.css

This script will

  • copy the nbextension for C3 into your IPython nbextensions folder,
  • append the code for loading the extension to your IPython profile's custom.js, and
  • add the required D3 and C3 code to your IPython profile's static resources folder.

Displaying C3 charts from IRacket

To display C3 charts, evaluate a cons cell whose car is the symbol 'c3-data and whose cdr is a jsexpr (from the json package) of the data structure to pass to C3's generate function.

Example:

(cons 'c3-data
      (hasheq 'data
              (hasheq 'columns
                      (list (list "data1" 30 200 100 400 150 250)
                            (list "data2" 50 20 10 40 15 25)))))

For more information on C3's data format, see the C3 reference, or for examples see the C3 examples page. For information on how to write JSON in Racket, see the Racket JSON package documentation.

Note that certain C3 features are not currently usable because they rely on using Javascript functions, which are not expressible in JSON.

Using the kernel

Run the IPython notebook server as you usually do, e.g.

ipython notebook

and create a new notebook with the Racket kernel.

iracket's People

Contributors

tgiannak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

iracket's Issues

Suggestion: Support for #lang

Racket's most powerful feature is the #lang module. It enables writing and using custom language. If the syntax is hard to support, perhaps consider the syntax (lang ____) for a one time setup in the whole REPL? Worse case scenario, I'll just go back to the long hand module declaration...

Thank you for your development!

Unable to use sqr

In DrRacket i am using (sqr 3) its showing 9 i.e running perfectly. But in notebook as soon as execute the block it says

sqr: undefined;
 cannot reference an identifier before its definition
  in module: top-level
  context...:
   eval-one-top12
   /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:510:0: call-with-custodian-shutdown
   /usr/share/racket/collects/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   .../more-scheme.rkt:261:28
   /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:878:5: loop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.