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

..and you said java dont curry

Name: Anonymous 2007-06-03 15:49 ID:xvzgDsaZ

   public class Currier<ARG1, ARG2, RET> {
       public interface CurriableFunctor<ARG1, ARG2, RET> {
           RET evaluate(ARG1 arg1, ARG2 arg2);
       }
  
       public interface CurriedFunctor<ARG2, RET> {
           RET evaluate(ARG2 arg);
       }
  
       final CurriableFunctor<ARG1, ARG2, RET> functor;
  
       public Currier(CurriableFunctor<ARG1, ARG2, RET> fn) { functor = fn; }
      
       public CurriedFunctor<ARG2, RET> curry(final ARG1 arg1) {
           return new CurriedFunctor<ARG2, RET>() {
               public RET evaluate(ARG2 arg2) {
                   return functor.evaluate(arg1, arg2);
               }
           };
       }
  
       public static void main(String[] args) {
           Currier.CurriableFunctor<Integer, Integer, Integer> add
               = new Currier.CurriableFunctor<Integer, Integer, Integer>() {
                   public Integer evaluate(Integer arg1, Integer arg2) {
                       return new Integer(arg1.intValue() + arg2.intValue());
                   }
           };
          
           Currier<Integer, Integer, Integer> currier
               = new Currier<Integer, Integer, Integer>(add);
          
           Currier.CurriedFunctor<Integer, Integer> add5
               = currier.curry(new Integer(5));
          
           System.out.println(add5.evaluate(new Integer(2)));
       }
   }

Name: Anonymous 2008-05-29 22:33

int *x = new int;

Name: Anonymous 2008-11-10 0:28

MOLEST MY COMMA is now a meme

Name: Anonymous 2008-11-10 13:28

>>83
Wrong.

Name: Anonymous 2008-11-10 14:50

>>39
You got me this time, anon!

Name: Anonymous 2008-11-10 16:12

x :: Integer

Name: Anonymous 2008-11-10 16:37

x <- newIORef 5

Name: Anonymous 2008-11-10 17:00

I never said that

Name: Anonymous 2008-11-10 20:23

Yes I did

Name: je 2009-01-29 23:35

u saved my homework ! kool! hahaha thxs

Name: Anonymous 2009-01-30 0:35

...and you said C# dont curry


using System;

namespace Currying
{
    class Curried<T1, TResult>
    {
        Func<T1, TResult> func;

        public Curried(Func<T1, TResult> f)
        {
            func = f;
        }

        public TResult Run(T1 t1)
        {
            return func(t1);
        }
    }

    class Curried<T1, T2, TResult>
    {
        Func<T1, T2, TResult> func;

        public Curried(Func<T1, T2, TResult> f)
        {
            func = f;
        }

        public Curried<T2, TResult> Run(T1 t1)
        {
            return new Curried<T2, TResult>(t2 => func(t1, t2));
        }

        public TResult Run(T1 t1, T2 t2)
        {
            return func(t1, t2);
        }
    }

    class Curried<T1, T2, T3, TResult>
    {
        Func<T1, T2, T3, TResult> func;

        public Curried(Func<T1, T2, T3, TResult> f)
        {
            func = f;
        }

        public Curried<T2, T3, TResult> Run(T1 t1)
        {
            return new Curried<T2, T3, TResult>((t2, t3) => func(t1, t2, t3));
        }

        public Curried<T3, TResult> Run(T1 t1, T2 t2)
        {
            return new Curried<T3, TResult>(t3 => func(t1, t2, t3));
        }

        public TResult Run(T1 t1, T2 t2, T3 t3)
        {
            return func(t1, t2, t3);
        }
    }

    class Program
    {
        static int Add(int a, int b)
        {
            return a + b;
        }

        static int Add3(int a, int b, int c)
        {
            return a + b + c;
        }

        static void Main(string[] args)
        {
            var cAdd = new Curried<int, int, int>(Add);
            var cAdd3 = new Curried<int, int, int, int>(Add3);
            var added = cAdd.Run(5).Run(4);
            var added3 = cAdd3.Run(1).Run(2).Run(3);
            Console.WriteLine(added);
            Console.WriteLine(added3);
        }
    }
}


...and you can continue writing more Curried<> classes like so.

Name: Anonymous 2009-01-30 1:18

i like curry.

Name: Anonymous 2009-01-30 1:43

>>92
Go back to /jp/, Ciel.

Name: Anonymous 2009-01-30 1:46

>>91
Needs more boost preprocessor metaprogramming.

Name: 94 2009-01-30 1:48

>>91
C#
Oh. I see now.

Name: Anonymous 2009-01-30 2:32

>>95
No, you see sharp.

Name: Anonymous 2009-01-30 2:40

>>96
That's it, thread over everyone. Pack up your stuff and go home.

Name: Anonymous 2009-01-30 13:12

>>97
But /prog/ is home.

Name: Anonymous 2009-03-06 8:21

Takes the creativity and   imagination that an   artist would have   is on paper   and what the   hell You know   I AM AN   Enterprise Programmer I   guarantee you it   will be instructional.

Name: Anonymous 2010-09-20 16:44

100 GET

Name: Anonymous 2010-09-20 17:06

This was a great thread, besides the reddit faggots.

Name: customs data 2011-08-05 2:35

Tradeinfo365 is a website that about exact, timely, and detailed global trade information,import and export data,the list of importers and exporters,customs data,supplier data.
http://www.tradeinfo365.com
http://www.tradeinfo365.com/page/TI365.html
http://www.tradeinfo365.com/page/Chinadata.html

Name: Anonymous 2011-08-05 11:15

anonymous classes are cool in some ways and fucking stupid excuses for real lambdas in other ways. C# is superior, although inner classes would be a nice touch to it.

Name: Anonymous 2011-08-05 14:37

>>,,,,,,,,,,,,,,,,,
Remember to sage your posts for the benefit of all /prog/ users.

Name: 花痴 2012-11-26 2:19

Name: 中絶薬 2012-11-26 2:20

Name: 媚薬 2012-11-26 2:20

Name: Anonymous 2012-11-26 2:24

108th post for BAD CHINESE KARMA!

Name: Anonymous 2012-11-26 9:54

Name: コスプレ衣装 2012-12-15 5:12

ウィッグ:http://www.besttojapan.com/_c104
ショートウィッグ:http://www.besttojapan.com/_c105
ショートカール:http://www.besttojapan.com/_c321
男性用ウィッグ:http://www.besttojapan.com/_c134
女性用ウィッグ:http://www.besttojapan.com/_c135
耐熱ウィッグ:http://www.besttojapan.com/_c136
ロング ウィッグ:http://www.besttojapan.com/_c320
人毛ウィッグ : http://www.besttojapan.com/p12756.html
ロングカール:http://www.besttojapan.com/p12978.html
ロングストレート:http://www.besttojapan.com/p12981.html
ウィッグ ボブ:http://www.besttojapan.com/p12926.html
涼宮 抱き枕:http://www.besttojapan.com/_c305  
東方 抱き枕:http://www.besttojapan.com/_c303
一騎当千 抱き枕:http://www.besttojapan.com/_c304  
アニメ 抱き枕:http://www.besttojapan.com/_c302
コスプレ衣装:http://www.besttojapan.com/_c189
生薬:http://www.besttojapan.com/_c181
麻黄:http://www.besttojapan.com/p6983.html
五味子:http://www.besttojapan.com/p6970.html
アバクロ新作:http://www.besttojapan.com/_c315
アバクロ:http://www.besttojapan.com/_c314
アバクロ メンズ :http://www.besttojapan.com/p12555.html
アバクロ レディース:http://www.besttojapan.com/p12683.html
デジタル フォトフレーム:http://www.besttojapan.com/_c141
デジタル写真フレーム:http://www.besttojapan.com/_c146
デジタルアルバム:http://www.besttojapan.com/_c147
ベビーアルバム:http://www.besttojapan.com/_c142
子供アルバム:http://www.besttojapan.com/p2700.html
ミニデジタルフォト:http://www.besttojapan.com/_c143
USB デジタルフォトフレーム:http://www.besttojapan.com/_c144
7インチ デジタル写真フレーム:http://www.besttojapan.com/_c150
3.5インチデジタル写真フレーム:http://www.besttojapan.com/_c149

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