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 minimal. *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 http://uk.my.yahoo.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This looks like a homework! Do you think this would not be plagiarism? - -- Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr> Comp. Sci. Dept., Bilkent University, Ankara www: http://www.cs.bilkent.edu.tr/~erayo GPG public key fingerprint: 360C 852F 88B0 A745 F31B EA0F 7C07 AE16 874D 539C -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8It8+fAeuFodNU5wRAkl+AJ0U1YOb2LDr/gfoWxzIj2joqwwA/ACdGUVz wRph4qeHqGxgEGolAvFPF+s= =R0ab -----END PGP SIGNATURE-----
participants (2)
-
Eray Ozkural (exa) -
J Brown