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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Dealing with higher order operations coupled with primitives
Date Thu, 21 Jun 2012 21:32:04 -0700
Organization A noiseless patient Spider
Lines 45
Message-ID <js0sg9$nbk$1@dont-email.me> (permalink)
References <6s2dnZ1-8r4ofH7SnZ2dnUVZ_s6dnZ2d@giganews.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Fri, 22 Jun 2012 04:32:10 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="IZQsHU8CwMUPnWgvh4wwWA"; logging-data="23924"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wLZWInFAoAGdh35D+iesQXt6ll6Nj83M="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1
In-Reply-To <6s2dnZ1-8r4ofH7SnZ2dnUVZ_s6dnZ2d@giganews.com>
Cancel-Lock sha1:/+czM+i6N0AYN/JA0fsHBwL5Jck=
Xref csiph.com comp.lang.java.programmer:15508

Show key headers only | 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