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

Pages: 1-

How I deuglified my function?

Name: Anonymous 2007-03-21 15:10 ID:4itzFHZ3

xam :: a -> a -> b
xam x y = foo (bar x) (bar y) (baz x) (baz y)

Name: Anonymous 2007-03-21 15:32 ID:nj0yMUqu

xam = (`ap` baz) . ap (flip . (. bar) . foo . bar) baz

Name: Anonymous 2007-03-21 15:44 ID:tW27ALqn

I don't know, use a real language?

Name: Anonymous 2007-03-21 15:46 ID:4itzFHZ3

>>3
Give me a less fugly solution in a REAL LANGUAGE and I'll consider.

Name: Anonymous 2007-03-21 15:54 ID:fJvri+4Z

Use arrows.

Name: Anonymous 2007-03-21 18:36 ID:jDsu417U


(define (xam x y)
  (foo (bar x) (bar y) (baz x) (baz y)))

Name: Anonymous 2007-03-21 18:39 ID:jDsu417U

(define (xam . xs)
  (apply foo (append (map bar xs) (map baz xs))))

works for any number of arguments

Name: Anonymous 2007-03-21 18:42 ID:jDsu417U

>>7
LETS SEE THAT IN HASKELL FUCKING LOL.

Name: Anonymous 2007-03-22 7:54 ID:T6QAOBUR

I don't know Lisp, but I believe this would be equivalent:

xam = lambda *x: return foo(map(bar, x) + map(baz,x))

Name: Anonymous 2007-03-22 8:25 ID:fm2tJkKn

>>9
it would not, fail.
you cant do varags in haskell like that you IDIOT

Name: Anonymous 2007-03-22 12:31 ID:fbzpKxrr

varargs are fail

Name: Anonymous 2007-03-22 13:58 ID:bXtZSDb5

>>11
Not so much in a purely functional language.

They are probably pretty hard to use in Haskell though, I found an implementation, but it was several levels beyond my understanding.

http://okmij.org/ftp/Haskell/vararg-fn.lhs

Name: Anonymous 2007-03-22 17:33 ID:aZ+o1ahN

>>11

They might be annoying to write, but whatever aggravation comes from it is often far outweighed by the benefit. Have you ever considered how many calls it would take to fprintf to print out most formatted strings if you could only print one string/field at a time?

It is not varargs that phail, but std i/o that does. Great way for new C++ students to learn how to abuse operator meanings (I suppose teaching of the principle of least suprise is postponed until a graduate level class these days).

Name: Anonymous 2007-03-22 17:37 ID:MaYJamg1

>>12
Eh, just pass a list of something. Doing printf() in Haskell is a) a bad idea and b) been done already (see Text.Printf and weep; I did).

Name: Anonymous 2009-01-14 12:57

LISP

Name: Anonymous 2009-03-06 12:46

Unix it seems the compiler that im   working in include   in my program   works good but   no entertainment value?

Name: Anonymous 2010-12-21 2:59

Name: Sgt.Kabu㌔姎kiman楏ꡊ 2012-05-28 23:31

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

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