Thu, 20 Dec 2001 16:20:42 +0000 (GMT)
hi, I am only a beginner of programming with Haskell,
how do I define each of the following:
* maxFirst :: (Int,Int) -> (Int,Int) -> (Int,Int)
which returns, of its two input tuples, the one whose
first component is the highest.
* Define a function
maximumFirst :: [(Int,Int)] -> (Int,Int)
which returns, from its list of input tuples, the
tuple whose first component is highest, assuming input
list is non-empty.
A function is given:
maxf :: [Int] -> Int
such that if maxf [x1,....,xn] = xi then
elem xi [x1,...,xn] == True
f xi >= f x1
f xi >= f x2
fxi >= f xn
* How do you define the function maxf (above) which
returns the element of its non-empty input list for
which f is maximal.
*and to define a function minf which returns the
element from its non-empty input list for which f is
*how do I define the function
maxIndexf :: [Int] -> Int
such that if
maxf xs = i
for non-empty xs, then
0 <= i < length xs
f (x s !! i) >= f (x s !! 0)
f (x s !! i) >= f (x s !! 1)
f (x s !! i) >= f (last xs)
that is it returns the index of the element of its
input list for which f is maximal.
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts