recursion

2003-08-21 Thread Tn X-10n
hi guys, may i know how to use recursive in a function. for example i have a function lets call it old which accept [[Bool]]-[(Int),(Int)]-(Int,Int) and return [(Int),(Int)] and now i have another function lets say its called new, which calls the previous functionand new will recursively check

RE: Database interface

2003-08-21 Thread Tim Docker
Tom Pledger wrote: How about introducing a Cursor abstract data type? doquery :: Process - String - b - (Cursor - b - IO (b, Bool)) - IO b stringv :: Cursor - CInt - IO String doublev :: Cursor - CInt - IO Double intv:: Cursor - CInt - IO Int

RE: Database interface

2003-08-21 Thread Bayley, Alistair
From: Tim Docker [mailto:[EMAIL PROTECTED] It also has the benefit that the function you pass to doquery can make other calls to doquery, without mucking up the 'current row' state. There would be one current row per Cursor, not one per Process. Is it normal or common to support

Re: Monads and Maybe

2003-08-21 Thread C T McBride
Hi Or, more generally, infixl 9 $ ($) :: Monad m = m (s - t) - m s - m t mf $ ms = do f - mf s - ms return (f s) or just liftM2 ($) or just ap OK, I'm a bad citizen and I never look things up in the library. If it isn't in the Gentle Introduction

Re: haskell reify, was sequencing data structures

2003-08-21 Thread Alastair Reid
Things that seem important (to me) are: - Do you want to observe cycles and or sharing? Yes. Of course this is very hard to do because of garbage collection. Only in the sense that holding onto an object pointer to detect a cycle might cause you to hold onto the object too -

Re: Monads and Maybe

2003-08-21 Thread Jon Cast
Konrad Hinsen [EMAIL PROTECTED] wrote: I have been following the recent Monad tutorial discussion with interest, and even read the tutorial, which is a useful addition to the existing Haskell documentation. So useful in fact that it raises a question... The whole monad mechanism seems to

Re: No safety in numbers

2003-08-21 Thread Jon Cast
Konrad Hinsen [EMAIL PROTECTED] wrote: I am trying to write a larger piece of code using only type constraints for all the numbers, not specific types, in order to be able to choose the precision as late as possible. Good for you! (I say this in all seriousness.) This works rather well

Re: Monads and Maybe

2003-08-21 Thread Martin Norbäck
tor 2003-08-21 klockan 22.26 skrev Jon Cast: Yes. Many complicated proposals have been made, but there's a straightforward, general mechanism: addMaybe :: Num alpha = Maybe alpha - Maybe alpha - Maybe alpha addMaybe a b = a = \x - b = \y - return (x + y)

Re: No safety in numbers

2003-08-21 Thread Konrad Hinsen
On Thursday 21 August 2003 22:42, Jon Cast wrote: (or any other type I declare it to be). Right. But: you can declare it to have type Fractional alpha = alpha, which is the same type the constant has in the middle of an expression. I can make such a declaration, but it still gets converted

Re: No safety in numbers

2003-08-21 Thread Konrad Hinsen
On Thursday 21 August 2003 23:23, Jon Cast wrote: I can make such a declaration, but it still gets converted to Double. How are you doing this? I'm not seeing the behavior you describe. module Foo where x = 0.5 :: Fractional a = a Then I run hugs Foo.hs and get: Foo :type x x :: Double

Re: No safety in numbers

2003-08-21 Thread David Roundy
On Thu, Aug 21, 2003 at 10:30:33PM +0200, Konrad Hinsen wrote: I might also declare all my constants to be Rational and use fromRational, but I don't know much about the Rational type. Do I have to worry about insufficient or compiler-dependent precision? I would guess that this is the best

Re: No safety in numbers

2003-08-21 Thread Tom Pledger
Konrad Hinsen writes: | On Thursday 21 August 2003 23:23, Jon Cast wrote: | I can make such a declaration, but it still gets converted to Double. | | How are you doing this? I'm not seeing the behavior you describe. | | module Foo where | x = 0.5 :: Fractional a = a Try x ::

RE: Database interface

2003-08-21 Thread Tom Pledger
Tim Docker writes: : | Is it normal or common to support multiple simultaneous queries on | a single DB connection? In transaction processing, yes. There's an idiom where you use one query to select all the (financial) transactions in a batch, but there's so much variation in how you need to

Re: No safety in numbers

2003-08-21 Thread Konrad Hinsen
On Thursday 21 August 2003 23:39, Tom Pledger wrote: Try x :: Fractional a = a x = 0.5 instead. That way, the type signature is in the right place to prevent defaulting. Right - thanks! Konrad. ___ Haskell-Cafe mailing list [EMAIL

Pascal Line in Haskell

2003-08-21 Thread Job L. Napitupulu
Can anyone help me how to make a function which takes an integer n 0 and returns the list of integers in Line of Pascal's Triangle. For examples, pascalLine 4 - [1,4,6,4,1] pascalLine 7 - [1,7,21,35,35,21,7,1] ___ Haskell-Cafe mailing list [EMAIL

Homework

2003-08-21 Thread thomas_bevan
Seeing as its thst time of year again and everyone is posting their homework, has anyone got any good puzzles to do? I wouldn't mind having a go at something a bit tricky. Tom ___ Haskell-Cafe mailing list [EMAIL PROTECTED]