title: Haskell: comparing elements in a tuple list
body: <p>Explanation of the project :</p>
  
  <p>Being given a list of 5 element tuples (eg. <code>[(String,Int,String,Int,Int)]</code>) , were the 1st element of the tuple represents the name of a worker and the 4th element represents his/her paycheck, I must make a function (called <code>biggestPay</code>) that gives the name of the worker with the biggest paycheck.</p>
  
  <p>Restrictions:</p>
  
  <p>Following the book "Learn you a Haskell for a great good" I can only use everything up to (including) Higher Order Functions and Prelude functions.</p>
  
  <p>My works so far:</p>
  
  <pre><code>getPay :: (String,Int,String,Int,Int) -&gt; Int
  getPay (_,_,_,a,_) = a 
  
  getName ::(String,Int,String,Int,Int) -&gt; String
  getName (a,_,_,_,_) = a
  
  getPayList :: [(String,Int,String,Int,Int)] -&gt; String
  getPayList [] = [] 
  getPayList xs = [ x | y &lt;- [0..(length xs)-1] , 
      if getPay(getPayList y:xs) &gt;= getPay(getPayList (y+1):xs) 
      then x is getName(getPayList y:xs) 
      else x is getName(getPayList (y+1):xs)]
  
  biggestPay :: [String] -&gt; String
  biggestPay [] = []
  biggestPay xs = drop ((length xs) -1) xs
  </code></pre>
  
  <p>My idea was compare the paychecks of all the workers and store their name in a list and then finally since the last element of the list would be the worker with the biggest paycheck I would drop all the other elements to get that worker's name only.</p>
  
  <p>However when I try to load this function into GHCI I get these errors:</p>
  
  <pre><code>ghci&gt; :l Pay.hs
  [1 of 1] Compiling Main             ( Pay.hs, interpreted )
  
  Pay.hs:9:19: Not in scope: `x'
  
  Pay.hs:11:22: Not in scope: `x'
  
  Pat.hs:11:24:
      Not in scope: `is'
      Perhaps you meant one of these:
        `xs' (line 9), `id' (imported from Prelude)
  
  Pay.hs:12:22: Not in scope: `x'
  
  Pay.hs:12:24:
      Not in scope: `is'
      Perhaps you meant one of these:
        `xs' (line 9), `id' (imported from Prelude)
  Failed, modules loaded: none.
  </code></pre>