In attempting to achieve satori, I tried to convert the following function to pointfree style: x `divisibleBy` y = x `mod` y == 0
My first attempt looked like this: divisibleBy = (== 0) . mod
Of course this doesn't work because mod is a two arg function and (.) requires a one arg function. So I turned to an acquaintance for help. He suggested: divisibleBy = ((== 0) . ). mod
This works, but it's fugly. In my original version it's immediately obvious what it's doing; the pointfree version is anything but obvious. Discuss.
Name:
Anonymous2007-03-16 9:50 ID:WI37uqOu
divisibleBy = curry ((== 0) . uncurry mod)
Name:
Anonymous2007-03-16 9:54 ID:+EPhLk32
>>2
Thanks I was trying to cook up a version using curry/uncurry, but I failed it. If anything though, I have to say that version is even worse; it reminds me of nothing so much as a Forth word that consists mostly of stack manipulation operators.
Um, theres a difference between "POINT FREE" and "POINTLESS"
When will you haskell fags ever shut up.
Name:
Anonymous2007-03-16 23:07 ID:9ACGaJIP
Man, I know haskell and I still think it sucks ass. You can do stuff with functional programming without the shit in haskell. Not to mention the blatant attempt to stick to referential transparency is pathetic.
Name:
Anonymous2007-03-17 10:51 ID:dZUCSQ/Q
>>20
agreed. haskell bites, its a shame it has better support for libs and platforms than lisp for example, because that seems to be the big reason for people using one language rather than another..
Name:
Anonymous2007-03-17 17:39 ID:ZFVOCIZT
OP here. I decided to factor out the "compose two functions where the second function takes two arguments" operation. After a bit of fiddling, I finally got it down to: foo = (.) . (.)
I called it foo because I didn't know what to call it. Then I realised I'd seen it somewhere before. Here it is: http://haskell.org/haskellwiki/Pointfree#Dot. I was pretty annoyed that I hadn't realised this, but hey I'm a Haskell noob and it was good practice at transforming equations. Like doing algebra except with functions.
So here's my final version: dot = (.) . (.)
divisibleBy = (== 0) `dot` mod
Which I think is pretty readable. Go pointfree style!
Name:
Anonymous2007-03-21 15:59 ID:+RtZz5SC
stf/b/
Name:
Anonymous2007-03-23 5:07 ID:Dv+koQAe
Pointless style is the win:
> isIndex x = notNull x && isDigits x
I think not!
> isIndex = uncurry (&&) . (&&&) notNull isDigits
Much better!
Name:
Anonymous2007-03-23 9:11 ID:l+fJkOzg
>>24
You should be able to use arrows to apply two functions to one argument.
Wikipedia does not have an article with this exact name. Please search for ``Simon Peyote Joints'' in Wikipedia to check for alternative titles or spellings.
* Start the Simon Peyote Joints article or add a request for it. * Search for "Simon Peyote Joints" in existing articles. * Look for pages within Wikipedia that link to this title.
Other reasons why this message may bedisplayed:
* If a page was recently created here, it may notyet be visible because of a delay in updating the database; wait a few minutes and try the purge function.
* Titles on Wikipedia are casesensitive except for the first character; please check alternate capitalizations and consider adding a redirect here to the correct title.
* If the page has been deleted, check the deletion log, and see ``Why have I been trolled''?.
Name:
Anonymous2009-03-06 7:35
The fortune You get bampu d regularly.
Name:
Anonymous2009-03-06 7:52
The programming environment sucks ass Fortunately the file format seems to be completely specified by adding the int infront the main the.