Hello again!

On Thu, Mar 11, 1999 at 08:09:54PM -0500, Steve Frampton wrote:
> [...]

> 1. Can I perform multiple statements on one line?  Eg.
>    foo :: Int -> [Char]
>    foo 0 = []
>    foo x = b = x - 5 * 3; c = b * 5; foo(x - b * c)

>    (The above is just a silly example...but you catch my meaning)

There are no statements in a functional language (except that
which is called statement as a component of the do-notation).

But the answer to what you obviously mean (judging from your
example) has already been given. (let or where)

> 2. I tried playing around with the foo function I was working with
>    last time, and am getting a different error now:
>    foo :: Int -> [Char]
>    foo 0 = []
>    foo x = ['1'] ++ foo(x div 10)

> [...]

That's a small syntactic mistake. Normal identifiers like foo, div, ...
are *never* infix operators. But you can turn every function of (at
least) two curried arguments into an infix operator by either giving
it an operator name (like ==), or enclosing the identifier in
backticks (like `div`). In fact, the latter would make your function
definition correct in my eyes.

Regards, Felix.


Reply via email to