develooper Front page | perl.perl6.language | Postings from May 2005

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
Brad Bowman
Date:
May 18, 2005 21:47
Subject:
Re: reduce metaoperator on an empty list
Message ID:
1116478011.2488.110.camel@oxum

> Another alternative is to give the user the option of specifying such
> a unit when using the reduction meta-operator, but this seems to work
> against the whole point of [+] (which is brevity). If you want to
> specify your own unit, use '&reduce'.

Can't the appropriate identity just be prepended?

> > my @a;
> > [+] @a; # 0? exception?
[+] (0, @a);

> > [*] @a; # 1? exception?
[*] (1, @a);

> > [<] @a; # false?
[<] (-Inf, @a);  # ???


Brad

-- 
People with intelligence will use it to fashion both true and false and will
try to push through whatever they want with their clever reasoning.  This is
injury from intelligence.
  Nothing you do will have effect if you do not use truth. -- Hagakure


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About