Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-31 Thread david48
On Fri, Jul 31, 2009 at 5:53 AM, Ryan Ingramryani.s...@gmail.com wrote: Read ($) as a parenthesis that extends as far to the right as possible; so you can write, for example: That doesn't always work, for example : map (+2) . map (*1) $ [1,2,3] = [4,6,8] Now replacing the $ by a parenthesis

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-31 Thread CK Kashyap
Subject: Re: [Haskell-cafe] Need feedback on my Haskell code On Fri, Jul 31, 2009 at 5:53 AM, Ryan Ingramryani.s...@gmail.com wrote: Read ($) as a parenthesis that extends as far to the right as possible; so you can write, for example: That doesn't always work, for example : map (+2) . map (*1

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-31 Thread Chaddaï Fouché
On Fri, Jul 31, 2009 at 2:12 PM, CK Kashyapck_kash...@yahoo.com wrote: I personally find map maySwitch (unfoldr go (x1,y1,0)) and map maySwitch $ unfoldr go (x1,y1,0) more intuitive. I can read it as map the maySwitch function over the list generated from the unfolding. Is there any

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-30 Thread CK Kashyap
Thanks David Regards, Kashyap From: david48 dav.vire+hask...@gmail.com To: CK Kashyap ck_kash...@yahoo.com Cc: Chaddaï Fouché chaddai.fou...@gmail.com; haskell-cafe@haskell.org Sent: Wednesday, July 29, 2009 4:43:52 PM Subject: Re: [Haskell-cafe] Need feedback

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-30 Thread Ryan Ingram
On Wed, Jul 29, 2009 at 4:06 AM, Johan Tibelljohan.tib...@gmail.com wrote: (map maySwitch . unfoldr go) (x1,y1,0) should work. which is the same as map maySwitch (unfoldr go (x1,y1,0)) People have stylistic differences with ($) vs. (.); I would write it as map maySwitch $ unfoldr go $

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-29 Thread CK Kashyap
not seem to work. Regards, Kashyap From: Chaddaï Fouché chaddai.fou...@gmail.com To: CK Kashyap ck_kash...@yahoo.com Cc: haskell-cafe@haskell.org Sent: Tuesday, July 28, 2009 7:10:38 PM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code On Tue, Jul 28

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-29 Thread Johan Tibell
On Wed, Jul 29, 2009 at 12:04 PM, CK Kashyap ck_kash...@yahoo.com wrote: It worked like a charm!!! I'd need more time to get my head around unfoldr I'd appreciate it very much if you could explain this line map maySwitch . unfoldr go $ (x1,y1,0) I did not fully understand the $ in that line

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-29 Thread david48
On Wed, Jul 29, 2009 at 12:04 PM, CK Kashyapck_kash...@yahoo.com wrote: map maySwitch . unfoldr go $ (x1,y1,0) I'm not an expert and I might say things the wrong way or without the required rigor, so with this disclaimer here's my explanation : go calculates a step of the line, given the

[Haskell-cafe] Need feedback on my Haskell code

2009-07-28 Thread CK Kashyap
Hi Everyone, I managed to write up the line drawing function using the following links - http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell line :: Point - Point - [Point] line (xa,ya) (xb,yb) = line' (x1,y1) (x2,y2)

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-28 Thread Neil Mitchell
Hi Kashyap, My first suggestion would be to run HLint over the code (http://community.haskell.org/~ndm/hlint) - that will spot a few easy simplifications. Thanks Neil On Tue, Jul 28, 2009 at 2:04 PM, CK Kashyapck_kash...@yahoo.com wrote: Hi Everyone, I managed to write up the line drawing

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-28 Thread CK Kashyap
) Regards, Kashyap From: Neil Mitchell ndmitch...@gmail.com To: CK Kashyap ck_kash...@yahoo.com Cc: haskell-cafe@haskell.org Sent: Tuesday, July 28, 2009 6:44:58 PM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code Hi Kashyap, My first suggestion

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-28 Thread Chaddaï Fouché
On Tue, Jul 28, 2009 at 3:04 PM, CK Kashyapck_kash...@yahoo.com wrote: Hi Everyone, I managed to write up the line drawing function using the following links - http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell I

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-28 Thread Felipe Lessa
Small tips: - Use swap and avoid those if's. - [a] ++ b is the same as a : b. - Factor out the first point that is always there. - Factor out line' arguments that don't change with the recursion. Untested: swap :: Bool - (a,a) - (a,a) swap False = id swap True = \(x,y) - (y,x) line ::

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-28 Thread CK Kashyap
chaddai.fou...@gmail.com To: CK Kashyap ck_kash...@yahoo.com Cc: haskell-cafe@haskell.org Sent: Tuesday, July 28, 2009 7:10:38 PM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code On Tue, Jul 28, 2009 at 3:04 PM, CK Kashyapck_kash...@yahoo.com wrote: Hi Everyone, I managed to write up the line