Name: Anonymous 2011-12-06 8:09
def fibs(n):
f0=0
f1=1
for i in xrange(2,n+1):
exec "f"+str(i)+"=f"+str(i-1)+"+"+"f"+str(i-2)
exec "del f"+str(i-2)
return eval("f"+str(i))
fizzbuzz=lambda n:[([[lambda c:c,lambda c:"fizz"],[lambda c:"buzz",lambda c:"fizzbuz"]][x%3==0][x%5==0](x)) for x in xrange(1,n)]
----
import Data.List
lindenmayer :: (Eq a) => [a] -> [(a,[a])] -> [a]
lindenmayer axiom rules =concatMap rule axiom
where
rule char = fromM (lookup char rules) char
fromM (Just x) = (\a -> x)
fromM Nothing = (\a -> [a])
lindenIterate axiom rules = iterate ((flip lindenmayer) rules) axiom
----
f0=0
f1=1
for i in xrange(2,n+1):
exec "f"+str(i)+"=f"+str(i-1)+"+"+"f"+str(i-2)
exec "del f"+str(i-2)
return eval("f"+str(i))
fizzbuzz=lambda n:[([[lambda c:c,lambda c:"fizz"],[lambda c:"buzz",lambda c:"fizzbuz"]][x%3==0][x%5==0](x)) for x in xrange(1,n)]
----
import Data.List
lindenmayer :: (Eq a) => [a] -> [(a,[a])] -> [a]
lindenmayer axiom rules =concatMap rule axiom
where
rule char = fromM (lookup char rules) char
fromM (Just x) = (\a -> x)
fromM Nothing = (\a -> [a])
lindenIterate axiom rules = iterate ((flip lindenmayer) rules) axiom
----