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

Haskell point-free

Name: Anonymous 2009-12-25 17:12

I have this:


ops :: [[Char] -> [Char]]
...
fun :: [Char] -> [[Char]]
fun str = zipWith ($) ops $ words str


How do I write fun in a point-free style? Dropping the argument gives me type errors.

Name: Anonymous 2009-12-25 17:14

I mean, I got this;

fun = (zipWith ($) ops).words

But it's ugly with all these parens. Is there a cleaner way?

Name: Anonymous 2009-12-25 17:17

godmaint i hate haskell

Name: sage 2009-12-25 17:18

1000 posts

Name: unburdened by purpose 2009-12-25 17:35

>>2
Remove them, duh.

>>4
That's one post.  Lrn2count.

Name: Anonymous 2009-12-25 17:59

What >>5 said. Also, can't you just write String to make your code clearer?

Name: Anonymous 2009-12-25 18:16

1000 posts

Name: Anonymous 2009-12-25 18:34

>>6
Thats not elitist enough.

Name: Over 8 Thread 2009-12-25 19:57

This thread has over 8 replies.
You can't reply anymore.

Name: Anonymous 2009-12-25 20:02

1000 posts

Name: Anonymous 2009-12-25 20:15

>>3-4,7,9-10
Why so hateful on OP? This thread is surely better than more of the half of the threads on /prog/'s front page. I don't even use Haskell, and I find it baffling that you'd want to prevent actual programming discussion.

Might I suggest you go back to /b/, and take those "sex vs programming" threads there with you too!

Name: Anonymous 2009-12-25 21:06

As long as you dont return a fucking pointer to the stack... its fine.

Have fun but its better to use pointers.

Each time some fucktarded c++ "programmer" goes arround passing huge classes as value a copy constructor dies.

Name: Anonymous 2009-12-25 21:06

As long as you dont return a fucking pointer to the stack... its fine.

Have fun but its better to use pointers.

Each time some fucktarded c++ "programmer" goes arround passing huge classes as value a copy constructor dies.

Name: Anonymous 2009-12-26 2:03

>>2
So fun = zipWith id ops . words

Remember, any time you pass ($) to a function that expects another function, you can substitute id and it will still work

Name: Anonymous 2009-12-26 2:04

>>12-13
Your dumb.

Name: Anonymous 2009-12-26 2:47

>>15
What about it?

Name: Anonymous 2010-01-07 2:51

>>14
don't get it

Name: Anonymous 2010-01-07 3:01

>>17
The fact that id x = x implies that (id x) y = (x) y, which is just a goofier (and syntactically illegal) way of saying id x y = x y.

Name: Anonymous 2010-01-07 3:51

FUCK OFF ALL YOU "HELPFUL" ASSHOLEE

Name: Anonymous 2010-01-07 4:01

>>19
Please. We are civilized here. You clearly meant: "HELPFUL" ANUSE

Name: Anonymous 2010-01-07 16:30

>>13,18
MIND=BLOWN

Name: Anonymous 2010-01-07 22:37

>>14
Why would you? ($) is just one character more and makes your intent clearer.

Name: Anonymous 2010-01-08 0:41

>>2
Function application has a higher precedence than any user-defined operator. Just remove the parens. Write sin x ^ 2, not (sin x) ^ 2. Also, please always use spaces around all binary operators, so that words . lines is consistent with Just . lines (since Just.lines means "the function lines in the module Just")

Name: Anonymous 2010-01-08 9:10

>>11
LOL!!!!!!

Name: Anonymous 2010-01-08 14:23

>>18
if it's syntactically illegal then what does it mean?

Name: Anonymous 2010-01-08 14:26

>>26
I'm no haskeller, but you I don't think you can compose type constructors with functions.

Name: Anonymous 2010-01-08 14:51

>>27
Type constructors are functions.

Name: Anonymous 2010-01-08 14:51

>>27
Wait, I fucked up there. Data constructors are functions. But you're still talking crap.

Name: Anonymous 2010-01-08 14:57

>>29
Yes, you're right. For some reason I thought he was referring to >>24, instead of >>18 and drew my conclusions based on that(with the presumption that it was wrong) Perhaps I should get my eyes tested (and learn Haskell while I'm at it)

Name: Anonymous 2010-01-08 17:05

>>18
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> let f = (+ 2)
Prelude> f 1
3
Prelude> (id f) 1
3

What do you mean "syntactically illegal"?

Name: Anonymous 2010-01-08 17:10

>>31
It think it's syntactically illegal to define the function as (f x) y = x y, as f would have to be a data constructor.

Name: Anonymous 2010-01-08 18:30

Prelude> let (f x) y = x y
Prelude> :t f
f :: (t -> t1) -> t -> t1
Prelude> let (f x) y = x y
Prelude> :t f
f :: (t -> t1) -> t -> t1
Prelude> :t let (f *** g) x y = (f x, g y) in (***)
let (f *** g) x y = (f x, g y) in (***)
  :: (t -> t1) -> (t2 -> t3) -> t -> t2 -> (t1, t3)
Prelude>

Name: Anonymous 2010-01-08 18:43

>>30
Learn Haskell? Have fun with that, professor...

Name: Anonymous 2010-01-08 21:23

Did you ever notice that GHCi uses faggot quotes?

Name: Anonymous 2010-01-08 22:17

>>35
I thought that was the original reason that people used them in Prgaue...

Name: Anonymous 2010-01-08 22:26

>>36
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-5.html#%_chap_Temp_2

Educators, generals, dieticians, psychologists, and parents program. Armies, students, and some societies are programmed. An assault on large problems employs a succession of programs, most of which spring into existence en route. These programs are rife with issues that appear to be particular to the problem at hand. To appreciate programming as an intellectual activity in its own right you must turn to computer programming; you must read and write computer programs -- many of them. It doesn't matter much what the programs are about or what applications they serve. What does matter is how well they perform and how smoothly they fit with other programs in the creation of still greater programs. The programmer must seek both perfection of part and adequacy of collection. In this book the use of ``program'' is focused on the creation, execution, and study of programs written in a dialect of Lisp for execution on a digital computer. Using Lisp we restrict or limit not what we may program, but only the notation for our program descriptions.

Name: Anonymous 2010-01-08 22:32

>>36
IIRC info pages use singular faggot quotes

Name: Anonymous 2010-01-08 22:43

>>38
Who the fuck uses info pages?

Name: Anonymous 2010-01-08 22:56

>>39
Emacs users

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