GithubHelp home page GithubHelp logo

calysto / calysto_scheme Goto Github PK

View Code? Open in Web Editor NEW
264.0 11.0 20.0 8.19 MB

A Scheme kernel for Jupyter that can use Python libraries

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.07% Python 21.23% Scheme 54.57% Jupyter Notebook 11.90% Dockerfile 0.01% TeX 12.21%
jupyter scheme python programming-language

calysto_scheme's Introduction

Calysto Scheme

You can try Calysto Scheme without installing anything by clicking on the following button:

Binder

Calysto Scheme is a real Scheme programming language, with full support for continuations, including call/cc. It can also use all Python libraries. Also has some extensions that make it more useful (stepper-debugger, choose/fail, stack traces), or make it better integrated with Python. For more details on using Calysto Scheme, see:

http://nbviewer.jupyter.org/github/Calysto/calysto_scheme/blob/master/notebooks/Reference%20Guide%20for%20Calysto%20Scheme.ipynb

In Jupyter notebooks, because Calysto Scheme uses MetaKernel, it has a fully-supported set of "magics"---meta-commands for additional functionality. This includes running Scheme in parallel. See all of the MetaKernel Magics.

Calysto Scheme is written in Scheme, and then translated into Python (and other backends). The entire functionality lies in a single Python file: https://github.com/Calysto/calysto_scheme/blob/master/calysto_scheme/scheme.py However, you can easily install it (see below).

Calysto Scheme in use:

Parallel Processing

To use Calysto Scheme in parallel, do the following:

  1. Make sure that the Python module ipyparallel is installed. In the shell, type:
pip install ipyparallel
  1. To enable the extension in the notebook, in the shell, type:
ipcluster nbextension enable
  1. To start up a cluster, with 10 nodes, on a local IP address, in the shell, type:
ipcluster start --n=10

or listening on a specific address:

ipcluster start --n=10 --ip=192.168.1.108
  1. Initialize the code to use the 10 nodes, inside the notebook from a host kernel (can be any metakernel kernel), type:
%parallel calysto_scheme CalystoScheme
  1. Run code in parallel, inside the notebook, type:

Execute a single line, in parallel:

%px (+ 1 1)

Or execute the entire cell, in parallel:

%%px
(* cluster_rank cluster_rank)

Results come back in a Scheme vector, in cluster_rank order. Therefore, the above would produce the result:

#10(0 1 4 9 16 25 36 49 64 81)

You can get the results back in the host Scheme by accessing the variable _ (single underscore).

Notice that you can use the variable cluster_rank to partition parts of a problem so that each node is working on something different.

In the examples above, use -e to evaluate the code in the host Scheme as well. Note that cluster_rank is not defined on the host machine, and that this assumes the host kernel is the same as the parallel machines.

A full notebook example can be found here: Mandelbrot.ipynb

Install

Ensure that your system has jupyter installed, and pyQt and qtconsole if you want to use the qtconsole option.

You can install Calysto Scheme with Python3:

pip3 install --upgrade calysto-scheme --user
python3 -m calysto_scheme install --user

or in the system kernel folder with:

sudo pip3 install --upgrade calysto-scheme
sudo python3 -m calysto_scheme install

You can also use the --sys-prefix to install into your virtualenv.

Change pip3/python3 to use a different pip or Python. The version of Python used will determine how Calysto Scheme is run.

Use it in the Jupyter console, qtconsole, or notebook:

jupyter console --kernel calysto_scheme
jupyter qtconsole --kernel calysto_scheme
jupyter notebook

You can also just use the Python program, but it doesn't have a fancy Read-Eval-Print Loop. Just run:

python calysto_scheme/scheme.py

Requires

  • Python3
  • metakernel (installed automatically)

Calysto Scheme can also be un under PyPy for increased performance.

Features

Calysto Scheme supports:

  • continuations
  • use of all Python libraries
  • choose/fail - built in fail and try again
  • produces stack trace (with line numbers), like Python
  • test suite

Planned:

  • Object-oriented class definitions and instance creation
  • complete Scheme functions (one can fall back to Python for now)

Limitations:

  • Runs slow on CPython; try PyPy

calysto_scheme's People

Contributors

dsblank avatar jasonhemann avatar jmarshallgit avatar rgbkrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

calysto_scheme's Issues

Lexical address is wrong for local-defines

I've been using Calysto to learn Scheme using the exercises from SICP in a Jupyter notebook. While running one of my examples, I noticed that it was failing where before it had passed. I believe that this is because the first time I ran the code, the function good-enough? was only defined in the local scope, while the second time I had just re-run all of the code in the notebook, causing it to be defined externally.

My code is located here: https://github.com/arlindohall/sicp/blob/master/Chapter1.ipynb

According to what I've learned so far, this should cause the local definition to be used, but Calysto used the global definition. I think this is the case, because the error I got was:

Traceback (most recent call last):
  File "In [7]", line 16, col 1, in 'sqrt'
  File "In [7]", line 14, col 3, in 'sqrt-iter'
  File "In [5]", line 2, col 7, in 'good-enough?'
  File "In [5]", line 14, col 11, in '-'
UnhandledException: unsupported operand type(s) for -: 'float' and 'NoneType'

and the global definition of good-enough? has two arguments, while the local one only has one argument.

Steps to reproduce:

  1. Open New Jupyter Notebook
  2. Enter the following in separate code blocks
(define (sqrt x)
  (define (square y)
    (* y y))
  (define (average a b)
    (/ (+ a b) 2))
  (define (good-enough? guess)
    (< (abs (- (square guess) x)) 0.001))
  (define (improve guess)
    (average guess (/ x guess)))
  (define (sqrt-iter guess)
    (if (good-enough? guess)
        guess
        (sqrt-iter (improve guess))))
  (sqrt-iter 1.0))
(sqrt 9)
(define (abs x)
  (if (< x 0)
      (- x)
      x))
(define (square x) (* x x))
(define (good-enough? guess x)
  (< (abs (- (square guess) x)) 0.001))
(define (sqrt x)
  (define (square y)
    (* y y))
  (define (average a b)
    (/ (+ a b) 2))
  (define (good-enough? guess)
    (< (abs (- (square guess) x)) 0.001))
  (define (improve guess)
    (average guess (/ x guess)))
  (define (sqrt-iter guess)
    (if (good-enough? guess)
        guess
        (sqrt-iter (improve guess))))
  (sqrt-iter 1.0))
(sqrt 9)
  1. Run in order, produces the following:
Traceback (most recent call last):
  File "In [5]", line 1, col 1, in 'sqrt'
  File "In [4]", line 14, col 3, in 'sqrt-iter'
  File "In [4]", line 11, col 9, in 'good-enough?'
  File "In [3]", line 7, col 11, in '-'
UnhandledException: unsupported operand type(s) for -: 'float' and 'NoneType'

Behavior in GNU Scheme:

1 ]=> (define (sqrt x)
  (define (square y)
    (* y y))
  (define (average a b)
    (/ (+ a b) 2))
  (define (good-enough? guess)
    (< (abs (- (square guess) x)) 0.001))
  (define (improve guess)
    (average guess (/ x guess)))
  (define (sqrt-iter guess)
    (if (good-enough? guess)
        guess
        (sqrt-iter (improve guess))))
  (sqrt-iter 1.0))

;Value: sqrt

1 ]=> (sqrt 9)

;Value: 3.00009155413138

1 ]=> (define (abs x)
  (if (< x 0)
      (- x)
      x))
(define (square x) (* x x))
(define (good-enough? guess x)
  (< (abs (- (square guess) x)) 0.001))
;Value: abs

1 ]=>
;Value: square

1 ]=> (define (sqrt x)
  (define (square y)
    (* y y))
  (define (average a b)
    (/ (+ a b) 2))
  (define (good-enough? guess)
    (< (abs (- (square guess) x)) 0.001))
  (define (improve guess)
    (average guess (/ x guess)))
  (define (sqrt-iter guess)
    (if (good-enough? guess)
        guess
        (sqrt-iter (improve guess))))
  (sqrt-iter 1.0))
;Value: good-enough?

1 ]=> (sqrt 9)

;Value: sqrt

1 ]=>
;Value: 3.00009155413138

screen shot 2017-12-29 at 1 10 14 am

screen shot 2017-12-29 at 1 11 29 am

screen shot 2017-12-29 at 1 12 04 am

screen shot 2017-12-29 at 1 12 22 am

`ipython console --kernel calysto_scheme` raises an error

[TerminalIPythonApp] WARNING | Subcommand `ipython console` is deprecated and will be removed in future versions.                              
[TerminalIPythonApp] WARNING | You likely want to use `jupyter console` in the future                                                          
Traceback (most recent call last):                                                                                                             
  File "C:\Program Files\Anaconda3\lib\site-packages\jupyter_console\ptshell.py", line 323, in init_kernel_info                                
    reply = self.client.get_shell_msg(timeout=1)                                                                                               
  File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\jupyter_client\client.py", line 77, in get_shell_msg                   
    return self.shell_channel.get_msg(*args, **kwargs)                                                                                         
  File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\jupyter_client\blocking\channels.py", line 57, in get_msg              
    raise Empty                                                                                                                                
queue.Empty                                                                                                                                    
                                                                                                                                               
During handling of the above exception, another exception occurred:                                                                            
                                                                                                                                               
Traceback (most recent call last):                                                                                                             
  File "C:\Program Files\Anaconda3\Scripts\ipython-script.py", line 10, in <module>                                                            
    sys.exit(start_ipython())                                                                                                                  
  File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\IPython\__init__.py", line 125, in start_ipython                       
    return launch_new_instance(argv=argv, **kwargs)                                                                                            
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 657, in launch_instance                            
    app.initialize(argv)                                                                                                                       
  File "<decorator-gen-113>", line 2, in initialize                                                                                            
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error                          
    return method(app, *args, **kwargs)                                                                                                        
  File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\IPython\terminal\ipapp.py", line 308, in initialize                    
    super(TerminalIPythonApp, self).initialize(argv)                                                                                           
  File "<decorator-gen-7>", line 2, in initialize                                                                                              
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error                          
    return method(app, *args, **kwargs)                                                                                                        
  File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\IPython\core\application.py", line 450, in initialize                  
    self.parse_command_line(argv)                                                                                                              
  File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\IPython\terminal\ipapp.py", line 303, in parse_command_line            
    return super(TerminalIPythonApp, self).parse_command_line(argv)                                                                            
  File "<decorator-gen-4>", line 2, in parse_command_line                                                                                      
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error                          
    return method(app, *args, **kwargs)                                                                                                        
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 514, in parse_command_line                         
    return self.initialize_subcommand(subc, subargv)                                                                                           
  File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\IPython\core\application.py", line 243, in initialize_subcommand       
    return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv)                                                               
  File "<decorator-gen-3>", line 2, in initialize_subcommand                                                                                   
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error                          
    return method(app, *args, **kwargs)                                                                                                        
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 452, in initialize_subcommand                      
    self.subapp.initialize(argv)                                                                                                               
  File "<decorator-gen-117>", line 2, in initialize                                                                                            
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error                          
    return method(app, *args, **kwargs)                                                                                                        
  File "C:\Program Files\Anaconda3\lib\site-packages\jupyter_console\app.py", line 141, in initialize                                          
    self.init_shell()                                                                                                                          
  File "C:\Program Files\Anaconda3\lib\site-packages\jupyter_console\app.py", line 114, in init_shell                                          
    client=self.kernel_client,                                                                                                                 
  File "C:\Program Files\Anaconda3\lib\site-packages\traitlets\config\configurable.py", line 412, in instance                                  
    inst = cls(*args, **kwargs)                                                                                                                
  File "C:\Program Files\Anaconda3\lib\site-packages\jupyter_console\ptshell.py", line 272, in __init__                                        
    self.init_kernel_info()                                                                                                                    
  File "C:\Program Files\Anaconda3\lib\site-packages\jupyter_console\ptshell.py", line 326, in init_kernel_info                                
    raise RuntimeError("Kernel didn't respond to kernel_info_request")                                                                         
RuntimeError: Kernel didn't respond to kernel_info_request                                                                                     
                                                                                                                                                ```

Division in python 3 throws an error

Input: (/ 1.0 2.0)
Output:

Traceback (most recent call last):
  File "In [45]", line 1, col 1, in '/'
UnhandledException: 'module' object has no attribute 'div'

No such kernel named calysto_scheme

I just tried pip installing calysto in my local virtualenv and ipython/jupyter 5 cannot find the kernel:

$ python --version
Python 2.7.10
$ pip freeze | grep -E 'jupyter|ipython|calysto|metakernel'
calysto-scheme==1.2.0
ipython==5.1.0
ipython-genutils==0.1.0
jupyter==1.0.0
jupyter-client==4.3.0
jupyter-console==5.0.0
jupyter-core==4.1.0
metakernel==0.14.0
$ ipython console --kernel calysto_scheme
[TerminalIPythonApp] WARNING | Subcommand `ipython console` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter console` in the future
Traceback (most recent call last):
  File "/home/mark/.virtualenvs/web/bin/ipython", line 11, in <module>
    sys.exit(start_ipython())
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/IPython/__init__.py", line 119, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 595, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-109>", line 2, in initialize
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 300, in initialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/IPython/core/application.py", line 446, in initialize
    self.parse_command_line(argv)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 295, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<decorator-gen-4>", line 2, in parse_command_line
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 488, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/IPython/core/application.py", line 236, in initialize_subcommand
    return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv)
  File "<decorator-gen-3>", line 2, in initialize_subcommand
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 426, in initialize_subcommand
    self.subapp.initialize(argv)
  File "<decorator-gen-113>", line 2, in initialize
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_console/app.py", line 137, in initialize
    self.init_shell()
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_console/app.py", line 105, in init_shell
    JupyterConsoleApp.initialize(self)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_client/consoleapp.py", line 334, in initialize
    self.init_kernel_manager()
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_client/consoleapp.py", line 288, in init_kernel_manager
    self.kernel_manager.start_kernel(**kwargs)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_client/manager.py", line 230, in start_kernel
    kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_client/manager.py", line 170, in format_kernel_cmd
    cmd = self.kernel_spec.argv + extra_arguments
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_client/manager.py", line 82, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/home/mark/.virtualenvs/web/local/lib/python2.7/site-packages/jupyter_client/kernelspec.py", line 175, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named calysto_scheme

jupyter console --kernel calysto_scheme gives similar results.

ParseError: bad try syntax: (try next)

error

(define tolerance 0.0000001)

(define (fixed-point f first-guess)
  (define (close-enough? v1 v2)
	(< (abs (- v1 v2)) tolerance))
  (define (try guess)
	(let ((next (f guess)))
	  (newline)
	  (display next)
	  (if (close-enough? next guess)
		next
		(try next))))
  (try first-guess))

I use the calysto_scheme kernel in my jupyter. The code was running ok in MIT-scheme but in scheme kernel there was something wrong. So I think there must have a bug in it.

thank you.

"define" or "begin" clashing with a keyword

Consider the following, which came up while writing a metacircular evaluator in calysto:

(case 'begin
  ((begin) 'foo-begin)
  ((define) 'foo-define)
  (else 'foo-else))

In Gambit Scheme, this produces

Gambit v4.9.4-132-gb9304a3b

> (case 'begin
  ((begin) 'foo-begin)
  ((define) 'foo-define)
  (else 'foo-else))
foo-begin

In calysto Scheme, this produces a parse error (I've run "test_all.ss" in the same REPL session to show that everything else seems OK):

└─(15:25:53 on master ✹ ✚ ✭)──> python scheme.py                                                                                                      2 ↵ ──(Tue,Dec27)─┘
Calysto Scheme, version 1.4.7
----------------------------
Use (exit) to exit
==> (case 'begin
  ((begin) 'foo-begin)
  ((define) 'foo-define)
  (else 'foo-else))... ... ... 
... 

Traceback (most recent call last):
ParseError: bad concrete syntax: (begin)
==> (load "test_all.ss")
Testing group 'defines'...
Testing group 'range'...
Testing group 'sort'...
Testing group 'main'...
Testing group 'mu-lambda'...
Testing group 'define'...
Testing group 'call/cc'...
Testing group 'try'...
Testing group 'loop'...
Testing group 'macros'...
Testing group 'datatype'...
Testing group 'named-parameters'...
=================
Testing completed!
  Time : 0.37 seconds
  Total tests defined: 247 
  Total tests tested : 247 
                Right: 247 
                Wrong: 0 
==> 

Any interest in Dockerizing?

I threw together a quick Dockerfile that spins up a Jupyter notebook with Calysto Scheme.

https://github.com/joearasin/docker-jupyter-scheme

Not sure if you've used Docker at all, but it means that, with Docker setup, one line in the shell will spin up a notebook running Calysto scheme. It's useful in the context of "it'd be nice to have a notebook to work through SICP with".

docker run -d -p 8888:8888 -v pwd:/notebooks joearasin/jupyter-scheme

Anyway, I was wondering if you had any interest in making it "official".

about useing python's libs

Excuse me... i want to use random in calysto_scheme .But I find that I don't know how to use a python lib in it......can you give me some structions ?

Division in python throws an unexpected result

i'm trying to write a simple python code for arithmetic operation
x=int(c[1])/320 print(c) print(c[1],round(x,2))

c=['S1069L03.jpg', '178', '142', '102', '\n']
(c[1],round(x.2))=('178', 0.0)

### the result is false because 178/320=0.55
does anyone have an idea how i can resolve it

Create classes and instances

In Python, you can create a new class like this:

A = type("A", (SUPERCLASS, ...), {ATTRIBUTE: ..., })

If we do it that way, and an ATTRIBUTE is a Scheme function, we have to manually pass in self.

Error Running Calysto Scheme notebook

While running the Calysto Scheme Language notebook (from master), I encountered this error :

(symbol "apple")

Traceback (most recent call last):
  File "In [177]", line 1, col 2
RunTimeError: unbound variable 'symbol'

I ll try to investigate as far as I can, but do people who know Calysto Scheme have any hint ?

README.md is not in the pip package

When I pip3 install --upgrade calysto-scheme, the installation fails with:

File "/private/var/folders/xb/5q674_3x6kl7v8vczp17p6gr0000gn/T/pip-build-3b37q2b2/calysto-scheme/setup.py", line 49, in <module>
        with open('README.md') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'README.md'

I downloaded calysto_scheme-0.8.2.tar.gz manually, and untarred the output:

tar -xvzf calysto_scheme-0.8.2.tar.gz 
x calysto_scheme-0.8.2/
x calysto_scheme-0.8.2/setup.py
x calysto_scheme-0.8.2/calysto_scheme/
x calysto_scheme-0.8.2/calysto_scheme/scheme.py
x calysto_scheme-0.8.2/calysto_scheme/__init__.py
x calysto_scheme-0.8.2/calysto_scheme/kernel.py
x calysto_scheme-0.8.2/calysto_scheme/__main__.py
x calysto_scheme-0.8.2/PKG-INFO

So the file isn't making it into the build.

Checking out the git repo and doing python setup.py install works fine.

Missing exp and log functions

The exp and log functions are undefined:

(exp 3)
Traceback (most recent call last):
  File "In [21]", line 1, col 2
RunTimeError: unbound variable 'exp'
(log 10)
Traceback (most recent call last):
  File "In [21]", line 1, col 2
RunTimeError: unbound variable 'log'

Docker image doesn't work anymore

Image jupyter/notebook doesn't exist anymore, so I took the liberty to create another image from nbgallery/jupyter-alpine (https://github.com/nbgallery/jupyter-alpine).

The alpine based image is supposed to be minimal. The final image is ~407MB.

The dockerfile is as follows:

FROM nbgallery/jupyter-alpine

RUN mkdir /app
WORKDIR /app

RUN pip3 install --upgrade pip
RUN pip3 install --upgrade jupyter
RUN pip3 install --upgrade notebook

RUN pip3 install --upgrade calysto-scheme
RUN python3 -m calysto_scheme install

CMD jupyter notebook --allow-root --ip=0.0.0.0 --port=80

It can be downloaded from my Docker hub as gchamon/calysto-scheme-alpine:latest and run as docker run -it -p 8888:80 -v $(pwd):/app gchamon/calysto-scheme-alpine

Feel free to use the Dockerfile at will!

Thanks for the kernel! It is helping me a lot with SICP

Different indistinguishable dicts

Hi, I noticed (after some troubleshooting) that dicts created by (dict ...) and by (python-eval "...") look exactly the same but behave differently:

(define a (python-eval "{'a' : 1}"))
a                                                           => {'a' : 1}
(define b (dict '(b : 2)))
b                                                           => {'b' : 2}
(get-item a 'a)                                             => 1
(get-item b 'b)                                             => error
(get-item a "a")                                            => 1
(get-item b "b")                                            => 2

While I know that that behaviour is to be expected, couldn't its representation be different to emphasize the incompatibility? e.g.
b => {"b" : 2}
or change the symbol-based one
a => {'a : 2}

Question regarding named parameters

Hi,

Is there a way to call (Python) host functions with named parameters like in this

import subprocess
process = subprocess.Popen(['echo', 'More output'],
                     stdout=subprocess.PIPE, 
                     stderr=subprocess.PIPE)

Calysto is great and I would like to use it more for everyday scripting.
Thanks,
Ben

exit and quit

(exit) should actually exit

quit should be re-defined or removed

"try" is a reserved word in Python

The classic SCIP handbook has this example:

(define tolerance 0.00001)

(define (fixed-point f first-guess)
  (define (close-enough? v1 v2)
    (< (abs (- v1 v2)) tolerance))
  (define (try guess)
    (let ((next (f guess)))
      (if (close-enough? guess next)
          next
          (try next))))
  (try first-guess))

The always code returns first-guess when running it in Calysto Scheme, while working correctly in other dialects of Scheme. When the code is modified by renaming try to something else, it works correctly.

I would expect it to either allows me to re-define the symbol, or at least throw an error if this is not allowed.

ImportError: cannot import name 'Iterable' from 'collections' (C:\Python310\lib\collections\__init__.py)

Windows 10 Pro

{micha} [122] --> python -V
Python 3.10.0

emacs:\org-new\org-mode
{micha} [123] --> pip install --upgrade calysto-scheme --user

emacs:\org-new\org-mode
{micha} [118] --> python -m calysto_scheme install --user
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\Python310\lib\runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\Python310\lib\runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\micha\AppData\Roaming\Python\Python310\site-packages\calysto_scheme\__init__.py", line 2, in <module>
    from .kernel import CalystoScheme
  File "C:\Users\micha\AppData\Roaming\Python\Python310\site-packages\calysto_scheme\kernel.py", line 4, in <module>
    from calysto_scheme import scheme
  File "C:\Users\micha\AppData\Roaming\Python\Python310\site-packages\calysto_scheme\scheme.py", line 16, in <module>
    from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections' (C:\Python310\lib\collections\__init__.py)

The kernel is actually installed, but it's broken for the reason shown. On my linux machine, which has Python 3.8, I get this message:

Deprecation warning: using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated 
since Python 3.3 and in 3.9 it will stop working.

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.