Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.haskell > #489

Re: Type question

From Mark Carroll <mtbc@bcs.org>
Newsgroups comp.lang.haskell
Subject Re: Type question
Date 2018-07-16 20:56 +0100
Organization none
Message-ID <87tvozkl9l.fsf@ixod.org> (permalink)
References <L453D.296188$R51.200199@fx03.iad>

Show all headers | View raw


On 16 Jul 2018, Black Swan wrote:

> I'm struggling with the following function:
>
> The following declaration works:

Don't know what happened to your whitespace here:

> data DividedResult = Result Integer | DividedByZero deriving (Eq, Show)
>
> dividedBy num denom =
> let
> (count,remainder,success) = x num denom 0
> in if success then (Result count) else DividedByZero
> where
> x num denom count
> | denom == 0 = (0,0,False)
> | num | otherwise = x (num - denom) denom (count + 1)

I can't quite make sense of this even if I try to correct the indents.
What's going on with the num guard bit?

If your news client is causing problems, happy to take a look at this
from some URL instead.

-- Mark

Back to comp.lang.haskell | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Type question Black Swan <root@rhok.xyz> - 2018-07-16 18:02 +0000
  Re: Type question Mark Carroll <mtbc@bcs.org> - 2018-07-16 20:56 +0100
  Re: Type question Mark Carroll <mtbc@bcs.org> - 2018-07-16 21:05 +0100
    RE: Re: Type question Black Swan <root@rhok.xyz> - 2018-07-17 15:04 +0000
      Re: Type question Mark Carroll <mtbc@bcs.org> - 2018-07-17 16:11 +0100

csiph-web