Slipkorn

Ayudanteando por un sueño

Apr 23rd, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Ayudanteando where
  2.  
  3. import Data.List
  4. type Concpdp = (String,Int)
  5. type Ayudante = (String,[Concpdp])
  6.  
  7.  
  8. ayudantes :: [Ayudante]
  9. ayudantes = [("Maria",[("ordenSuperior",6),("expresionLambda",7),("listasPorComprension",8)]),("Fede",[("aplicacionParcial",9),("listasPorComprension",6)]),("Cristian",[("currificación",5),("aplicacionParcial",9),("tuplas",9),("ordenSuperior",8)]),("Roberto",[("expresionLambda",6),("listasPorComprension",6)]),("Juan",[("tuplas",4),("ordenSuperior",5)])]
  10.  
  11.  
  12. ayudante :: Ayudante
  13. ayudante = ("mara",[("ordenSuperior",6),("expresionLambda",7),("listasPorComprension",8)])
  14.  
  15. -- 1)
  16.  
  17. conapunt :: [Concpdp]->[Int]
  18. conapunt = map snd
  19.  
  20. --a)
  21. puntema :: [Ayudante]->Int->Int
  22. puntema y x =  (length.filter (/=[])) [(filter (==x).conapunt) conps|(_,conps)<-y]
  23.  
  24. --b)
  25. aprendecrec :: Ayudante->Bool
  26. aprendecrec (_,x) = conapunt x == sort (conapunt x)
  27.  
  28. -- 2)
  29. conastring :: [Concpdp]->[String]
  30. conastring = map fst
  31.  
  32.  
  33. alf :: Ayudante->Int
  34. alf (x,y) | (elem "ordenSuperior".conastring) y = 9
  35.           | otherwise = 5
  36.  
  37. gonza :: Ayudante->Int       
  38. gonza (x,y) = (length.conastring) y
  39.  
  40. franco :: Ayudante->Int
  41. franco (t,[]) = 0
  42. franco t = (snd.maximum) [((length x),(head x))|x<- (grupos t)]
  43.          where grupos (x,y) = (group.sort.conapunt) y
  44.  
  45. --a)         
  46. puntajes :: [(a->b)]->a->[b]         
  47. puntajes f x = [y x | y<-f]
  48.  
  49. --b)
  50. sumpunt :: (Num b) =>[(a->b)]->a->b
  51. sumpunt f = (sum.puntajes f)
  52.  
  53. --c)
  54. buenayudante :: (Ord a, Num a) =>[b->a]->b->Bool
  55. buenayudante f x = (minimum.puntajes f) x >= 7
  56.  
  57. --d)
  58. --puntajes [alf,gonza,franco,\(m,n) -> minimum ([r|(t,r)<-n])] ("Maria",[("ordenSuperior",7),("aplicacionParcial",8),("tuplas",7)])
  59.  
  60. -- 3)
  61. --a)
  62.  
  63. tresmejores :: (Ayudante->Int)->[Ayudante]->[String]
  64. tresmejores f lista = mayamen [(f xy,x) |xy@(x,y)<-lista]
  65.                     where
  66.                     mayamen = map snd.take 3.reverse.sort
  67.  
  68. masde7:: Ayudante->Int
  69. masde7 (x,y) = (length.filter (>=7).map snd) y
  70.  
  71.  
  72. tema:: String->Ayudante->Int
  73. tema s (a,c) = cabeza [n|(t,n)<-c,t==s]
  74.                 where
  75.                 cabeza [] = 0 --si dicho tema no lo sabe el valor de puntuación es 0
  76.                 cabeza a = head a
  77.  
  78. --b)
  79. --tresmejores (tema "ordenSuperior") ayudantes
  80. --["Cristian","Maria","Juan"]
Advertisement
Add Comment
Please, Sign In to add comment