haskell and prolog
hi there. i have to do an assignment in these two langiages, ive looked for the compilers and only found one for haskell the ghc or something, this however doesnt seem to work, ive installed it and when i run it a dos screen pops up and disapears immediatly.
can any of you guys give me a definate link to a working compi;ler for both these langauges it will be greatly appreciated.
i dont know anything about these things so i need direct help please
thanks people
What is probably happening is that you aren't providing the required parameters when you run your Haskell compiler, so the compiler issues an error message and exits. Because the compiler exits, the DOS window shuts and you don't get to read the error message.
Try running it in a dos window (Start menu->Run->"command"). Then the window won't close when the compiler does.
Here's the standard prolog interpreter.
http://www.swi-prolog.org/download.html
Try running it in a dos window (Start menu->Run->"command"). Then the window won't close when the compiler does.
Here's the standard prolog interpreter.
http://www.swi-prolog.org/download.html
As for Haskell, I learnt Haskell with Hugs98, haven't had any experience with other compilers, but it worked :)
hi ive just typed in what all the help files i have looked at claim are the way you state a function in haskell, the line was
testWord = "testing" and i get
:ERROR - Syntax error in input (unexpected `=')
how do i make testWord = "testing"?
i dont understand
testWord = "testing" and i get
:ERROR - Syntax error in input (unexpected `=')
how do i make testWord = "testing"?
i dont understand
that is a correct haskell function, but you can't define functions in the interpreter. You need to create them in a file, and then load them.
foo.hs:
testWord :: String
testWord = "testing"
in hugs:
> :l foo.hs
> testWord
"testing"
>
(you don't have to define the types of functions, but it is good practice.)
/Nico
foo.hs:
testWord :: String
testWord = "testing"
in hugs:
> :l foo.hs
> testWord
"testing"
>
(you don't have to define the types of functions, but it is good practice.)
/Nico
Day 3 of learn haskell.
Ive looked at a load of tutorials and quite frankly im fed up of reversing strings and removing certain characters from them
What i need is to (ill explain this how i would in pascal, c or c++, i know haskel does not work like this)
i need to create a record that holds say a name ::string, age :: int, on/off :: bool
how do i store something like this and then use a function to get the name of the thing, its age and is it turned on or off.
how would i answer a question like. is archibold turned on?
thanks
Ive looked at a load of tutorials and quite frankly im fed up of reversing strings and removing certain characters from them
What i need is to (ill explain this how i would in pascal, c or c++, i know haskel does not work like this)
i need to create a record that holds say a name ::string, age :: int, on/off :: bool
how do i store something like this and then use a function to get the name of the thing, its age and is it turned on or off.
how would i answer a question like. is archibold turned on?
thanks
something like this, perhaps..
just remember you can't have truly mutable varibles in haskell without monads.
hope it helps..
/Nico
data Record = Record { name :: String, age :: Int, onoff :: Bool}myrecord = Record { name = "Nico", age = 666, onoff = True}myfunc :: Record -> Stringmyfunc rec = let r_name = name rec; r_age = age rec; r_onoff = onoff rec; in "Name: " ++ r_name ++ "\nAge: " ++ (show r_age) ++ "\nOn: " ++ (show r_onoff)
just remember you can't have truly mutable varibles in haskell without monads.
hope it helps..
/Nico
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement