You are not logged in.

#1 2007-01-31 14:48:53

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

haskell - simple help needed [solved]

I started to learn haskell and the 1st thing i tried is to define a function. I tried it both in hugs and in hsci:

Prelude> square x = x * x
<interactive>:1:9: parse error on input `='

the same (more or less) happens in hugs.

I'm lost here, how do i define a function?

Thanks!

Last edited by drakosha (2007-02-01 12:56:05)

Offline

#2 2007-01-31 16:36:44

diffyQ
Member
From: dc
Registered: 2006-08-29
Posts: 13

Re: haskell - simple help needed [solved]

at the interpreter, you need to precede definitions with a 'let'.  e.g.,

let square x = x*x

you should think of the interpreter prompt as running inside a 'do' block.

Offline

#3 2007-02-01 00:25:46

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

Re: haskell - simple help needed [solved]

10x!

Offline

Board footer

Powered by FluxBB