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

Point-free programming style

Name: Anonymous 2009-01-04 19:30

How do I write the factorial function in point-free?

fact n = foldr1 (*) [1..n]

Which is faster
add1 = 1 +
or
add1 x = 1 + x
???

Name: FrozenVoid !FrOzEn2BUo 2009-01-05 8:49

bench(loop,factorial,10000000,45)=567ms
10000000 loops in 567ms.
Can your Haskell do this?
function factorial(x){for(var i=x-1;i>0;i--){x*=i};return x}

function bench(x,y,z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10){var d=new Date();var std=d.getTime();var res=x(y,z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10);var d2=new Date();var std2=d2.getTime();
var diff=std2-std;return diff}
function loop(x,y,z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10){for(var i=y-1;i>-1;i--){var res=x(z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10)}}

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