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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
Edward Cherlin
Date:
June 9, 2005 00:39
Subject:
Re: reduce metaoperator on an empty list
Message ID:
200506090048.18643.cherlin@pacbell.net
On Tuesday 07 June 2005 22:35, Sam Vilain wrote:
> Let's look at the type of one of the many `reduce' variants in
> Haskell;
>
>    foldr1 :: (a -> a -> a) -> [a] -> a
>
> This is the Perl6ish;
>
>    sub reduce( ::Code{( ::(someType), ::(someType) ) returns
> ::(someType)} $func, Array of ::(someType) ) returns
> ::(someType);
>
> ie, the function $func supplied must take and return arguments
> of a single type.  So you have come to the same conclusion as
> the FP folk :-).

I agree with that from the APL, J, Haskell, and FP directions and 
several more.

That means that we have to straighten out the functions that can 
return either a Boolean or an item of the argument type. 
Comparison functions < > <= >= = != should return only Booleans, 
IMHO, and the same for the string functions lt and gt and the 
rest. It also means that we need primitive functions (operators) 
like max and min that only return one of the arguments, and that 
can also be used with a reduction operator (metaoperator).
-- 
Edward Cherlin
Generalist & activist--Linux, languages, literacy and more
"A knot! Oh, do let me help to undo it!"
--Alice in Wonderland
http://cherlin.blogspot.com

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