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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
Sam Vilain
Date:
June 9, 2005 21:28
Subject:
Re: reduce metaoperator on an empty list
Message ID:
42A916E2.5070802@vilain.net
TSa (Thomas SandlaƟ) wrote:
> I'm not sure but Perl6 could do better or at least trickier ;)
> Let's assume that < > <= >= when chained return an accumulated
> boolean and the least or greatest value where the condition was
> true. E.g.
>   0 < 2 < 3   returns  0 but true
>   1 < 2 < 1   returns  1 but false
>   4 < 5 < 2   returns  2 but false

An interesting idea, but seems a bit heavy..

> Is it correct that [min] won't parse unless min is declared
> as an infix op, which looks a bit strange?
> if 3 min 4 { ... }

Sure.  Again there is a Haskell example to heed closely here; for instance, the function:

    divMod :: (Integral a) => a -> a -> (a, a)

Can be written as either;

    divMod 42 9

or:

    42 `divMod` 9

The reverse direction is ();

    (+) :: (Num a) => a -> a -> a

    (+) 7 5

    7 + 5

Sam.

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