Language Pyrex
| Date: | 08/21/07 |
| Author: | Ilan Schnell |
| URL: | http://ilan.schnell-web.net/ |
| Comments: | 1 |
| Info: | http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ |
| Score: |
# beer.pyx
#
# Author: Ilan Schnell
#
# Invocation:
# $ pyrexc beer.pyx
# $ gcc -c -fPIC -I/usr/local/include/python2.5 beer.c
# $ gcc -shared beer.o -o beer.so
# $ python -c "import beer"
cdef bob(int n):
cdef char *s
s = "bottles"
if n:
if n==1: s = "bottle"
return "%s %s of beer" % (n, s)
else:
return "no more %s of beer" % s
for n in xrange(99, 0, -1):
print bob(n)+" on the wall, "+bob(n)+"."
print "Take one down and pass it around, "+bob(n-1)+" on the wall."
print
print "No more bottles of beer on the wall, "+bob(0)+"."
print "Go to the store and buy some more, "+bob(99)+" on the wall."
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments