[Chicken-users] Chicken for python

2013-11-08 Thread mfv
Hello all, 

first time post here. 

I decided to give lisp et al. a go and started to dive into functional
programming. Since I come from a Python background, I wonder if there is a
chance that one could extend Python with the use of a library compiled by
Chicken. CHICKEN produces portable and efficient C, so maybe there is a
way to feed some chickens to the snake?

For the record, I posted the question at stackoverflow:
http://stackoverflow.com/questions/19849048/chicken-for-python-extending-python-with-the-use-of-a-shared-library

Any opinions, ideas, comments? 

Cheers!

  
 

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for python

2013-11-08 Thread Daniel Leslie
You'd likely just have to wrap the C functions that exist for embedding
Chicken in other apps.

http://wiki.call-cc.org/embedding

http://wiki.call-cc.org/man/4/Embedding

-Dan


On Fri, Nov 8, 2013 at 3:54 PM, m...@freeshell.de wrote:

 Hello all,

 first time post here.

 I decided to give lisp et al. a go and started to dive into functional
 programming. Since I come from a Python background, I wonder if there is a
 chance that one could extend Python with the use of a library compiled by
 Chicken. CHICKEN produces portable and efficient C, so maybe there is a
 way to feed some chickens to the snake?

 For the record, I posted the question at stackoverflow:

 http://stackoverflow.com/questions/19849048/chicken-for-python-extending-python-with-the-use-of-a-shared-library

 Any opinions, ideas, comments?

 Cheers!




 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Chicken for python

2013-11-08 Thread mfv
Hello all, 

I am fairly new to the world of lisp, and yet I am hacking a bit here and
there to get a better idea of functional programming et al.   

I recently posted a question to stackoverflow that might be of interest to
the chicken people and python people as well, and I thought that it might be
a good idea to bring it up on this list as well: 

http://stackoverflow.com/questions/19849048/chicken-for-python-extending-python-with-the-use-of-a-shared-library

The question was whether chicken scheme could be use to create libraries for
python, as chicken is able to produce solid C code.

Cheers, 

  Piotr

  

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for python

2013-11-08 Thread mfv
Hi Dan, 


On Fri, Nov 08, 2013 at 03:58:26PM -0800, Daniel Leslie wrote:
 You'd likely just have to wrap the C functions that exist for embedding
 Chicken in other apps.
 
 http://wiki.call-cc.org/embedding
 
 http://wiki.call-cc.org/man/4/Embedding


I shall try this out. Thanks!

 - piotr 




___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for python

2013-11-08 Thread Ivan Raikov
Hello,

   There was a similar attempt a couple of years ago, and the results were
posted here:

http://lists.gnu.org/archive/html/chicken-users/2011-01/msg00179.html

This is about embedding a Chicken REPL inside Python, which a little bit
different than what you want,
but it might be helpful.

   -Ivan



On Sat, Nov 9, 2013 at 8:54 AM, m...@freeshell.de wrote:

 Hello all,

 first time post here.

 I decided to give lisp et al. a go and started to dive into functional
 programming. Since I come from a Python background, I wonder if there is a
 chance that one could extend Python with the use of a library compiled by
 Chicken. CHICKEN produces portable and efficient C, so maybe there is a
 way to feed some chickens to the snake?

 For the record, I posted the question at stackoverflow:

 http://stackoverflow.com/questions/19849048/chicken-for-python-extending-python-with-the-use-of-a-shared-library

 Any opinions, ideas, comments?

 Cheers!




 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for Python Programmers

2009-01-07 Thread Tobia Conforto

John Cowan wrote:
In Scheme all functions are lambdas: but they don't have the  
restrictions of Python lambdas.


Maybe one could say:

In Scheme all functions are lambdas and all lambdas are functions.   
They have the power of regular Python functions and the usefulness of  
Python lambdas, at the same time.


SRFI-1 provides append!, but note that you must capture the return  
values of destructive (!) list functions; you can't just rely on the  
side effects.  There is no guarantee that append! will actually side- 
effect its arguments; you are just permitting it to do so.


Here I would add a generic explanation on the conceptual difference  
between Python's and Scheme's destructive operations, more than a  
list of behaviours.  Let's see if I can come up with something:


A Python list is a single object. Its destructive or in-place  
operations (such as sort or append) simply operate on the whole object  
and modify it in-place.  Scheme values that are also single objects  
(such as strings, pairs, or hash tables) behave in the same way.


A Scheme list, on the other hand, is a chain of simpler objects  
(pairs) so you typically don't have operations that modify the whole  
list in-place.  Both Scheme's destructive and non-destructive list  
operations return a new list with the requested changes.  This new  
list (the return value of the operation) will have to be used  
somewhere to be of use, even if just by re-assigning it to the same  
variable:


(set! some-list (reverse! some-list))   ;same as: some_list.reverse()

The difference between non-destructive and destructive operations is  
that the destructive sort may build the new list by recycling the  
pairs that make up the old chain.  A destructive operation is often  
more optimized, but you should only use it when: 1. you are  
reassigning the return value to the same variable, see above, or 2.  
you won't use that variable anymore, after the operation.


This strange paradigm comes from Scheme's emphasis on functional  
programming.  A Scheme programmer doesn't expect a variable (such as  
some-list above) to change its immediate, direct value, unless he  
explicitly set!s it to a new value.  The functional programming  
style completely avoids set!, or variable assignment, and that is  
why this paradigm makes sense.



-Tobia


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for Python Programmers

2009-01-05 Thread John Cowan
Jack Trades scripsit:

 After noticing Chicken for blub programmers on the wiki some months ago, I
 decided a good way to learn Scheme would be to produce a similar document.

Great work!  Just a few notes:

Altering a character in a *literal* string is never a good idea in any
language; if you must demonstrate string-set!, use one constructed
with the make-string or string procedures.  Some Schemes disallow
string-set! if they know the string is literal.

In Scheme all functions are lambdas: but they don't have the
restrictions of Python lambdas.

Nested functions: note that Scheme can do internal defines.

Unfortunately, hash tables in Chicken aren't very efficient yet: in
small examples, a-lists are better.

SRFI-1 provides append!, but note that you must capture the return
values of destructive (!) list functions; you can't just rely on the side
effects.  There is no guarantee that append! will actually side-effect
its arguments; you are just permitting it to do so.

One way to do a LIST-SET! operation is:
(define (list-set! list index new) (set-car! (drop list index) new))
This works because the result of drop is guaranteed to share storage
with the original list.

Similarly, list-insert! is:
(define (list-insert! list index new)
  (append (take list index) (list new) (drop list index)))

To reverse in place when possible, use reverse!, but note that you must
capture the result: (set! r (reverse! r)) Ditto with sort!.

List-copy makes a shallow copy of a list.  Here's a tree-copy function:
(define (tree-copy x)
  (if (pair? x) (cons (tree-copy (car x)) (tree-copy (cdr x))) x))

-- 
Deshil Holles eamus.  Deshil Holles eamus.  Deshil Holles eamus.
Send us, bright one, light one, Horhorn, quickening, and wombfruit. (3x)
Hoopsa, boyaboy, hoopsa!  Hoopsa, boyaboy, hoopsa!  Hoopsa, boyaboy, hoopsa!
  --Joyce, Ulysses, Oxen of the Sun   co...@ccil.org


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for Python Programmers

2008-12-30 Thread felix winkelmann
On Tue, Dec 30, 2008 at 1:21 AM, Jack Trades jacktradespub...@gmail.com wrote:

 After noticing Chicken for blub programmers on the wiki some months ago, I
 decided a good way to learn Scheme would be to produce a similar document.
 It's ~50 pages long and written as one large table with various
 sub-headings.  At last count (end of November), it had over 400 solutions to
 about 250 problems in both Chicken and Python, as well as tons of links to
 further documentation and reference material.  It's currently still in draft
 form, which means there's some editing notes and blank sections here and
 there.

 I plan to continue working on the document, but I've been sidetracked
 developing a DSL for an evolutionary programming language, which I also plan
 to document in this format.  If you'd like to comment or contribute I'd be
 appreciative and would eventually be willing to translate it to wiki format
 if there is an interest.


This is excellent, Jack! I'm sure this would be extremely interesting to
Scheme/Chicken newcomers. If you could convert it to wiki-syntax, we would
be more than happy to add it to the wiki.


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for Python Programmers

2008-12-30 Thread Peter Bex
On Tue, Dec 30, 2008 at 02:01:48PM +0100, felix winkelmann wrote:
  I plan to continue working on the document, but I've been sidetracked
  developing a DSL for an evolutionary programming language, which I also plan
  to document in this format.  If you'd like to comment or contribute I'd be
  appreciative and would eventually be willing to translate it to wiki format
  if there is an interest.
 
 
 This is excellent, Jack! I'm sure this would be extremely interesting to
 Scheme/Chicken newcomers. If you could convert it to wiki-syntax, we would
 be more than happy to add it to the wiki.

+1

Great stuff.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth


pgpWshyEQzSio.pgp
Description: PGP signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Chicken for Python Programmers

2008-12-29 Thread Jack Trades
After noticing Chicken for blub programmers on the wiki some months ago, I
decided a good way to learn Scheme would be to produce a similar document.
It's ~50 pages long and written as one large table with various
sub-headings.  At last count (end of November), it had over 400 solutions to
about 250 problems in both Chicken and Python, as well as tons of links to
further documentation and reference material.  It's currently still in draft
form, which means there's some editing notes and blank sections here and
there.

I plan to continue working on the document, but I've been sidetracked
developing a DSL for an evolutionary programming language, which I also plan
to document in this format.  If you'd like to comment or contribute I'd be
appreciative and would eventually be willing to translate it to wiki format
if there is an interest.

Unfortunately I used this document as a test of Google Docs, and under all
but the most ideal circumstances the formatting sucks.  Nevertheless you can
find the raw Google Docs version at the address below.  If you like it, hate
it or would like to see additions please comment.

http://docs.google.com/Doc?id=dgxzmhv_579j3m5kc5

Jack Trades
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken for Python Programmers

2008-12-29 Thread Matthew Welland
On Monday 29 December 2008 05:21:21 pm Jack Trades wrote:
 After noticing Chicken for blub programmers on the wiki some months
 ago, I decided a good way to learn Scheme would be to produce a similar
 document. It's ~50 pages long and written as one large table with various
 sub-headings.  At last count (end of November), it had over 400 solutions
 to about 250 problems in both Chicken and Python, as well as tons of
 links to further documentation and reference material.  It's currently
 still in draft form, which means there's some editing notes and blank
 sections here and there.

 I plan to continue working on the document, but I've been sidetracked
 developing a DSL for an evolutionary programming language, which I also
 plan to document in this format.  If you'd like to comment or contribute
 I'd be appreciative and would eventually be willing to translate it to
 wiki format if there is an interest.

 Unfortunately I used this document as a test of Google Docs, and under
 all but the most ideal circumstances the formatting sucks.  Nevertheless
 you can find the raw Google Docs version at the address below.  If you
 like it, hate it or would like to see additions please comment.

 http://docs.google.com/Doc?id=dgxzmhv_579j3m5kc5

Jack, I think your doc is potentially really useful for beginners. I haven't 
read the whole thing but did notice the following:

Construction of a Populated Dictionary
Chicken:  I'm sure there's a standard way to do this, but did not find it in 
a quick search.

AFAIK there is no readable representation of a hash table. The closest you 
can get is by using an alist:

csi (hash-table-ref (alist-hash-table '( (a . 1)(b . 2))) a)
1

I'd like to see a yaml reader/writer egg but haven't had time to tackle it 
myself.

Matt
-=-


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users