By Hans Nowak ·
January 15, 2009 at 10:49 am
· Tags:
haskell
I didn’t know this, but there are two specialized search engines for Haskell: Hoogle and Hayoo!. Both of them allow you to search for Haskell functions by name or type signature.
Unlike its general-purpose counterpart, Hayoo seems to return the best results. For example, you can look for all packages that have a function foldl, or for the functions in the Data.Tree.AVL package.
Now if we only had such a beast for Python… :-)
Permalink ::
By Hans Nowak ·
December 29, 2007 at 10:09 am
· Tags:
haskell, python
Check this post, which demonstrates the power of Haskell’s list comprehensions:
f :: Int -> [ (Int, Int, Int) ]
f n = [ (x, y, z) |
x <- [ 1 .. n ],
y <- [ x+1 .. n ],
z <- [ y+1 .. n ],
(x * x) + (y * y) == (z * z) ]
I first thought there was some special magic going on, like maybe some Prolog-like matching, but then I realized that you can do the same in Python:
def f(n):
return [(x,y,z)
for x in range(1, n+1)
for y in range(x+1, n+1)
for z in range(y+1, n+1)
if x*x + y*y == z*z]
print f(20)
(Which isn’t so surprising after all, as Python “borrowed” list comprehensions from Haskell… but still.)
Permalink ::