| wtd - Jul-25-2005 server time |
| GHCi is the interactive version of GHC. Quite like Hugs, but in my opinion, better. |
| Endow - Jul-25-2005 server time |
| "i"? I think I already have GHC correctly installed. |
| wtd - Jul-25-2005 server time |
| You should try GHCi. http://haskell.org/ghc/ |
| Endow - Jul-25-2005 server time |
| The worst part is that WinHugs isn't working alright for me. |
| wtd - Jul-24-2005 server time | ||
| Odd. On my Linux box:
|
| Endow - Jul-24-2005 server time |
| Ah yes but it doens't have anything to do with the capitalized M.I checked.I still get the same error message. |
| wtd - Jul-23-2005 server time |
| Module "Main" should be in "Main.hs". If I indicated otherwise in the turorial, then I apologize. |
| Endow - Jul-23-2005 server time |
| module Main where Just like in the tutorial |
| wtd - Jul-23-2005 server time | ||
What's the first line of main.hs? |
| Endow - Jul-23-2005 server time |
| Okay I'm new here and I'm also new to functional programming.But my problem isn't with the actual programming.I'm reading that evry helpful Haskell tutorial but when I'm in Hugs and I want to load a module and I do this : :load main this appears : ERROR "main.hs":1 - Syntax error in input (unexpected backslash (lambda) ) The truth is I never even used the command prompt before but it doens't look liekt hat's the problem. |
| wtd - Jul-04-2005 server time | ||
Using "div", which does integer math... (div 3 2 == 1, for instance)
Oh, and you'll notice that I used a new definition of "pow" for an exponent of 1. |
| WhoDoo - Jul-03-2005 server time | ||
| Thank you x^0 = 1 x^n = (x^(n/2))^2 if n is even x^n = x * (x^(n/2))^2 if n is odd I use this code
but when trying it by typing pow (2,4) or something, I get an error |
| wtd - Jul-02-2005 server time | ||||||||||||||||||
For the first question, this should work.
However, Haskell already makes this pretty easy. You could simply write:
As for your second question... the closest thing to nothing in Haskell is (). However, it sounds more like you're thinking of the Maybe data type. Let's consider a fairly simple example. You want to find the position of an element in a list. First, we know that nothing we could possibly be located anywhere in an empty list. So the item and the counter don't even matter.
But it might be in a non-empty list.
Here we used the Just constructor for the Maybe data type, whereas we had used the Nothing constructor previously. Now if I were to run:
I would get in return:
But if I run:
I get:
I can use pattern matching to discern this at run-time.
|
| WhoDoo - Jul-01-2005 server time |
| I've just started learning Haskell and I have two questions. First of all, what if I want to do two things in a function? (like first I want to print something, then I would like to do a function call). I want to make a simple recursive "for-loop" like this myfunc nbr = putStr "This is " ++ nbr; if nbr < 10 then myfunc(nbr+1) else return somethings like that, but the code above isnt working. In C it would be something like void function(int nbr) { cout<<"This is" << nbr; if(nbr < 10) function(nbr+1); else return; } my second question is, what if I dont want a function to return something? Mabye I have a function that should print something if I pass a certain argument. Since I need an else-statement, what should I put there in order to do "nothing"? |