Yes thank you I completely agree. A stash of sieves, plus data mine
this very archive for our earlier work on this topic.
My only suggestion is you include a generator version e.g.:
Using Python 3:
>>> g = Primes()
>>> next(g)
-1
>>> next(g)
2
>>> next(g)
3
>>> next(g)
5
etc.
Generators are c
I'd like to suggest, that some sort of sieve could be included,
for instance as a non very fancy example something like
def primes(n):
s = set(range(3,n+1,2))
if n >= 2: s.add(2)
m=3
while m * m < n:
s.difference_update(range(m*m, n+1, 2*m))
m += 2
while m not in
I'm putting together a list of topics for a proposed course entitled
"Programming for Scientists and Engineers". See the link to CS2 under
http://ece.arizona.edu/~edatools/index_classes.htm. This is intended as a
follow-on to an introductory course in either Java or C, so the students will
ha
If anyone is interested in running Python 3 or Python 2.6 on Ubuntu
Intrepid and having all the bits work, like Tkinter, etc. I've written
up the process and and the needed packages for compiling from source on
a blog post here...
http://learnpython.wordpress.com/2009/01/14/installing-python-30
Yes, note that my Pascal's includes it, with an embedded zip. Another place
list comprehension comes up is in our naive definition of totatives as:
def totative(n):
return [ t for t in range(1, n) if gcd(t, n) == 1]
i.e. all 0 < t < n such that (t, n) have no factors in common (are
relativel
I like this.
I think another 'must include' for math classes would be list comprehension
syntax. Not an algorithm in itself, but an important way of thinking. It's
what we try to get them to do using set notation, but in math classes it
seems simply like a formality for describing domains, nothi