|
 |
Yesterday, this came into existence:
http://tryhaskell.org/
It gives you a window with a command prompt. Type any valid Haskell
expression and it'll execute it and display the result (and the type
signature of the result).
There used to be another site like this powered by LambdaBot, but it
stopped working years ago. Finally we have a working site again.
Of course, it's still alpha quality. The command history is screwier
than a squirrel. I/O operations fail with a perplexing error message.
(OK, there's no obvious way for I/O operations to work - and we don't
want random Internet users deleting files off the server! - but the
error could be better.) Most seriously, you can only enter 1-liners. You
can't define variables and then use them later; the entire thing you
want to execute must be a single, giant, line.
Actually, I have a question. How is a site like this even physically
possible in the first place? How can you send a request to the server
and receive a response without reloading the entire page? I've seen
several sites do this, but I have no idea how it's possible.
Anyway, the site has a small (OK tiny) tutorial which will teach you
about 0.1% of Haskell. (Type "help" to start it.) Here's a few cryptic
1-liners for producing "interesting" results:
product [1..100]
(Calculate 100!, which is really, really big by the way.)
let f = 1 : 1 : zipWith (+) f (tail f) in f
(Infinite list of Fibonacci numbers.)
let p = [1] : map (\r -> zipWith (+) ([0] ++ r) (r ++ [0])) p in p
(Infinite Pascal's triangle.)
scanl (*) 1 [1..]
(Infinite list of factorials.)
[ (x,y) | x <- ['A'..'Z'], y <- [1..10] ]
(Cartesian product of two lists.)
filterM (const [True, False]) "ABC"
(All sublists of a list.)
Obviously the "infinite" results get truncated to be finite. Also if you
ask the server to do anything really slow, it terminates the calculation
after a second or so and just says "terminated".
Post a reply to this message
|
 |