Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #15508

Re: Dealing with higher order operations coupled with primitives

From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Dealing with higher order operations coupled with primitives
Date 2012-06-21 21:32 -0700
Organization A noiseless patient Spider
Message-ID <js0sg9$nbk$1@dont-email.me> (permalink)
References <6s2dnZ1-8r4ofH7SnZ2dnUVZ_s6dnZ2d@giganews.com>

Show all headers | View raw


On 6/21/2012 8:08 PM, Aaron W. Hsu wrote:

> public class IotaSumReduce {
>
>    public static int sum(int n) {
>      int res = 0;
>      for (int i = 0; i < n; i++) res += i;
        return res;
>    }


This method needed a return value; I assume you meant res.


> public class AplIotaSumReduce {
>
>    private static class Sum extends Function {
>      void apply(AplArray res, AplArray arg) {
>        Function plus = new AplArray.PlusFunction();


I think we are going to need the definitions of Function, AplArray, 
AplArray.PlusFunction, etc.  I'd prefer not to guess how you are 
implementing these right now.


>        res.iota(arg);
>        res.reduce(plus, res);

I think I understand reduction, but shouldn't it return a value?  I 
don't see how you reduce in-place like this;  are you over-writing the 
0th element or something?


>
> This program runs much much slower for me.


We'll definitely need more code.  We're far afield of what Java normally 
does.  Trying to guess at your implementation is counter productive, and 
standard ways of doing this don't exist afaik, as Java programmers don't 
normally (ever?) do this sort of thing.

I'll agree with others: Haskell/Clojure seem a better fit.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Dealing with higher order operations coupled with primitives "Aaron W. Hsu" <arcfide@sacrideo.us> - 2012-06-21 22:08 -0500
  Re: Dealing with higher order operations coupled with primitives Gina Engli <gengli239777@gmail.com> - 2012-06-21 23:17 -0400
    Re: Dealing with higher order operations coupled with primitives "Aaron W. Hsu" <arcfide@sacrideo.us> - 2012-06-22 15:13 -0500
  Re: Dealing with higher order operations coupled with primitives markspace <-@.> - 2012-06-21 21:32 -0700
    Re: Dealing with higher order operations coupled with primitives Gina Engli <gengli239777@gmail.com> - 2012-06-22 02:31 -0400
      Re: Dealing with higher order operations coupled with primitives Fred Greer <fggreer@nospam.invalid> - 2012-06-22 06:36 +0000
        Re: Dealing with higher order operations coupled with primitives Gina Engli <gengli239777@gmail.com> - 2012-06-22 02:43 -0400
          Re: Dealing with higher order operations coupled with primitives Lew <lewbloch@gmail.com> - 2012-06-22 12:45 -0700
            Re: Dealing with higher order operations coupled with primitives Sixteen of Seventeen <sseventeen@gmail.com> - 2012-06-22 18:24 -0400
              Re: Dealing with higher order operations coupled with primitives Lew <noone@lewscanon.com> - 2012-06-22 19:59 -0700
                Re: Dealing with higher order operations coupled with primitives Sixteen of Seventeen <sseventeen@gmail.com> - 2012-06-22 23:16 -0400
                Re: Dealing with higher order operations coupled with primitives Lew <noone@lewscanon.com> - 2012-06-22 22:13 -0700
                Re: Dealing with higher order operations coupled with primitives Borg Queen <queen@unimatrix.zero> - 2012-06-23 01:18 -0400
                Re: Dealing with higher order operations coupled with primitives Lew <noone@lewscanon.com> - 2012-06-23 07:59 -0700
                Re: Dealing with higher order operations coupled with primitives Borg Queen <queen@unimatrix.zero> - 2012-06-23 12:12 -0400
    Re: Dealing with higher order operations coupled with primitives "Aaron W. Hsu" <arcfide@sacrideo.us> - 2012-06-22 15:28 -0500
      Re: Dealing with higher order operations coupled with primitives Gina Engli <gengli239777@gmail.com> - 2012-06-22 18:25 -0400
  Re: Dealing with higher order operations coupled with primitives Roedy Green <see_website@mindprod.com.invalid> - 2012-06-22 00:33 -0700
    Re: Dealing with higher order operations coupled with primitives "Aaron W. Hsu" <arcfide@sacrideo.us> - 2012-06-22 15:31 -0500
  Re: Dealing with higher order operations coupled with primitives rossum <rossum48@coldmail.com> - 2012-06-22 13:00 +0100
    Re: Dealing with higher order operations coupled with primitives markspace <-@.> - 2012-06-22 07:45 -0700
      Re: Dealing with higher order operations coupled with primitives Lew <lewbloch@gmail.com> - 2012-06-22 12:45 -0700
        Re: Dealing with higher order operations coupled with primitives markspace <-@.> - 2012-06-22 13:34 -0700
          Re: Dealing with higher order operations coupled with primitives Lew <noone@lewscanon.com> - 2012-06-22 20:04 -0700
    Re: Dealing with higher order operations coupled with primitives "Aaron W. Hsu" <arcfide@sacrideo.us> - 2012-06-22 15:22 -0500
      Re: Dealing with higher order operations coupled with primitives Lew <lewbloch@gmail.com> - 2012-06-22 14:27 -0700
  Re: Dealing with higher order operations coupled with primitives "Aaron W. Hsu" <arcfide@sacrideo.us> - 2012-06-22 15:14 -0500

csiph-web