RE: Haskell-Cafe Digest, Vol 28, Issue 66

From: Daniel Carrera
Robert Dockins wrote: -divides a b = (mod a b == 0) +divides a b = (mod b a == 0)
Oh, thanks. My program assumed one way to define 'divides' and the example assumed the other.
When I wrote it I was thinking of (divides a) being a function that tells me if the input divides 'a'.
Thanks!
Cheers, Daniel.
Daniel, Have you used Haskell's infix notation? It can help keep the order straight for operators like these. You can write a `mod` b -- instead of mod a b a `divides` b -- instead of divides a b. This can help with readability, too. Chad Scherrer

Scherrer, Chad wrote:
Have you used Haskell's infix notation? It can help keep the order straight for operators like these. You can write
a `mod` b -- instead of mod a b a `divides` b -- instead of divides a b.
This can help with readability, too.
No, I haven't. That's neat, very neat. Thanks for the tip. I just tried it, and all these are valid: (a `divides`) b (`divides` b) a That's neat because then you can make derived functions and compositions and all sorts of neat stuff. Cheers, Daniel -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. /

On Tue, Dec 20, 2005 at 09:12:51PM +0000, Daniel Carrera wrote:
No, I haven't. That's neat, very neat. Thanks for the tip.
I just tried it, and all these are valid:
(a `divides`) b (`divides` b) a
The annoyance in this business (which *is* very cool) is that you really have to decide when you name your functions whether they're meant to be infix or not. At least I've never come up with a verb form that makes sense either infix or prefix... :( -- David Roundy http://www.darcs.net
participants (3)
-
Daniel Carrera
-
David Roundy
-
Scherrer, Chad