Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python.announce > #1261

Calico Scheme in Python

Date 2014-04-13 23:52 -0400
Subject Calico Scheme in Python
From Doug Blank <doug.blank@gmail.com>
Newsgroups comp.lang.python.announce
Message-ID <mailman.9245.1397467735.18130.python-announce-list@python.org> (permalink)

Show all headers | View raw


We are writing to let you know of a recent spin-off from our Scheme
implementation work: we now have a version implemented in Python. This is a
full Scheme with proper tail-call recursion handling written in Python.

We also added some interesting Python-Scheme interactions:

* Scheme can use Python functions and libraries
* You can define Scheme functions for use in Python
* Python's list class serves the role for Scheme's vector class

Some sample uses:

You can just use calicoscheme.py as a script in Python, IronPython, or
Jython:

$ python calicoscheme.py
Calico Scheme, version 3.0.0
----------------------------
Use (exit) to exit
==> (+ 1 1)
2

This environment has access to Python's built-ins through
calicoscheme.ENVIRONMENT:

==> (sum '(1 2 3))

sum is found in the Python environment.

You can also import and use Python libraries directly:

==> (using "math" "numpy")
(math numpy)
==> (math.sin 3.14)
0.0015926529164868282
==> (numpy.array 10)
array(100)
==> (exit) # or control+d

You can also use calicoscheme inside Python:

$ python
>>> import calicoscheme
>>> calicoscheme.ENVIRONMENT = globals()    # set the environment to the
locals here
>>> calicoscheme.start_rm()
==> (+ 1 1)
2
==> (define! f (lambda (n) (+ n 1)))     ### define! puts it in the
external env
==> (exit)
goodbye

And back in Python you can call the define! function using Scheme's
infrastructure:

>>> f(100)
101

You can also call into Scheme like so:

>>> calicoscheme.execute_string_rm("(define x 23)")
<void>
>>> calicoscheme.execute_string_rm("x")
23

To download and get more information, please see:

http://calicoproject.org/Calico_Scheme

Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread


Thread

Calico Scheme in Python Doug Blank <doug.blank@gmail.com> - 2014-04-13 23:52 -0400

csiph-web