Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pointfree style considered pointless?

Name: Anonymous 2007-03-16 9:40 ID:+EPhLk32

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: Anonymous 2007-03-16 9:50 ID:WI37uqOu

divisibleBy = curry ((== 0) . uncurry mod)

Name: Anonymous 2007-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.

Name: Anonymous 2007-03-16 11:37 ID:Heaven

Point-free + more than one argument -> Battletoads.

Name: carrotCake 2007-03-16 11:44 ID:whSjmfWu

Why the fuck are they prototyping Perl 6 in Haskell?

I got my comit bit a few weeks back.

Name: Anonymous 2007-03-16 11:55 ID:8/l5G5N9

>>5
To add to the insanity

Name: Anonymous 2007-03-16 11:56 ID:g+k0Vq7Z

flip flip 0 . ((==) .) . mod
Pointfree is not guaranteed to produce code that makes sense, of course. Don't abuse it.

Name: Anonymous 2007-03-16 12:02 ID:dijv5bR6

Lambdabot beats you puny hoo-mans at poinless pointfreeness.

Name: Anonymous 2007-03-16 12:22 ID:8QHCjNUL

Dear god there are 4tards in #haskell?

Name: Anonymous 2007-03-16 12:29 ID:+t2wgEdu

Pointfree is sometimes pointless. Better be properly explicit, after all code should be written for humans first and compilers second.

Name: Anonymous 2007-03-16 12:41 ID:dijv5bR6

>>9
You are no longer safe. Run.

Name: Anonymous 2007-03-16 13:38 ID:8QHCjNUL

    <me> @pl \f g x y -> f (g x y)
    <lambdabot> (.) . (.)

Name: Anonymous 2007-03-16 13:43 ID:+EPhLk32

>>9
Anonymous is legion.

Name: Anonymous 2007-03-16 16:53 ID:dijv5bR6

What the fuck? Someone posted this on reddit. The world is about to end.

To redditors not familiar with 4chan: nothing to see here, mostly some pretty competent programmers trolling each other for no obvious reason.

Name: Anonymous 2007-03-16 16:59 ID:jzChVXNP

>>14
Lies, I searched reddit for ``4chan'' but found nothing linking to prog.

Name: Anonymous 2007-03-16 17:03 ID:dijv5bR6

Name: Anonymous 2007-03-16 17:13 ID:jzChVXNP

O lawd, there was a programming.reddit.com...

Name: Anonymous 2007-03-16 17:15 ID:dijv5bR6

O lawd, there was a dis.4chan.org...

Name: Anonymous 2007-03-16 17:56 ID:tIhrmf7l

Um, theres a difference between "POINT FREE" and "POINTLESS"

When will you haskell fags ever shut up.

Name: Anonymous 2007-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: Anonymous 2007-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: Anonymous 2007-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: Anonymous 2007-03-21 15:59 ID:+RtZz5SC

stf/b/

Name: Anonymous 2007-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: Anonymous 2007-03-23 9:11 ID:l+fJkOzg

>>24
You should be able to use arrows to apply two functions to one argument.

Name: Anonymous 2007-03-23 9:48 ID:FRcpyRwL

isIndex = uncurry (&&) . notNull &&& isDigits

that's pretty clear if you know what &&& does

Name: Anonymous 2007-03-23 11:41 ID:l+fJkOzg

>>26
And what does &&& do? Educate me.

Name: Anonymous 2007-03-23 11:57 ID:FRcpyRwL

it takes two functions f and g and makes a function which when applied on a value x produces the tuple (f x, g x)

i.e. swap x = (snd &&& fst) x = (snd x, fst x)

Well actually it's more complicated, but that's the basic idea when your arrows (a b c) are just functions (b -> c)

Name: Anonymous 2007-03-23 12:15 ID:hDeMuEbE

Sounds pointless

Name: Anonymous 2007-04-26 11:02 ID:3se3pZtb

dot should be called ..
and then f...g x y z for f (g x y z)
etc

Name: Anonymous 2007-04-26 11:35 ID:Iv1HDd2Z

>>30
Yeah, sadly that's not valid syntax. I wonder if it's possible to macro it.

Name: Anonymous 2007-04-26 18:33 ID:pU9AYo+N

Madness.

Name: Anonymous 2007-04-27 17:17 ID:lB4iOLBs

Haskell operators are so nasty garbage. How do I do shit? Oh yeah you use the .?(( operator!

Name: Anonymous 2007-04-28 12:55 ID:Op+kBYcn

Pointfree style is pointless. Why waste time worrying about syntax when you can do actual programming in Haskell.

Name: Anonymous 2007-04-28 14:45 ID:Heaven

>>34
because you can't do actual programming in haskell.

Name: Anonymous 2007-07-30 12:11 ID:Heaven

here's what it would look like in a decent language.
: divisible_by? ( x y -- ? ) mod zero? ;

Name: Anonymous 2008-03-26 14:21

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 be displayed:

    * If a page was recently created here, it may not yet be visible because of a delay in updating the database; wait a few minutes and try the purge function.

    * Titles on Wikipedia are case sensitive 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: Anonymous 2009-03-06 7:35

The fortune You get   bampu d regularly.

Name: Anonymous 2009-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.

Name: Anonymous 2009-03-07 21:19

bump

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List