Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Ayudanteando where
- import Data.List
- type Concpdp = (String,Int)
- type Ayudante = (String,[Concpdp])
- ayudantes :: [Ayudante]
- 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)])]
- ayudante :: Ayudante
- ayudante = ("mara",[("ordenSuperior",6),("expresionLambda",7),("listasPorComprension",8)])
- -- 1)
- conapunt :: [Concpdp]->[Int]
- conapunt = map snd
- --a)
- puntema :: [Ayudante]->Int->Int
- puntema y x = (length.filter (/=[])) [(filter (==x).conapunt) conps|(_,conps)<-y]
- --b)
- aprendecrec :: Ayudante->Bool
- aprendecrec (_,x) = conapunt x == sort (conapunt x)
- -- 2)
- conastring :: [Concpdp]->[String]
- conastring = map fst
- alf :: Ayudante->Int
- alf (x,y) | (elem "ordenSuperior".conastring) y = 9
- | otherwise = 5
- gonza :: Ayudante->Int
- gonza (x,y) = (length.conastring) y
- franco :: Ayudante->Int
- franco (t,[]) = 0
- franco t = (snd.maximum) [((length x),(head x))|x<- (grupos t)]
- where grupos (x,y) = (group.sort.conapunt) y
- --a)
- puntajes :: [(a->b)]->a->[b]
- puntajes f x = [y x | y<-f]
- --b)
- sumpunt :: (Num b) =>[(a->b)]->a->b
- sumpunt f = (sum.puntajes f)
- --c)
- buenayudante :: (Ord a, Num a) =>[b->a]->b->Bool
- buenayudante f x = (minimum.puntajes f) x >= 7
- --d)
- --puntajes [alf,gonza,franco,\(m,n) -> minimum ([r|(t,r)<-n])] ("Maria",[("ordenSuperior",7),("aplicacionParcial",8),("tuplas",7)])
- -- 3)
- --a)
- tresmejores :: (Ayudante->Int)->[Ayudante]->[String]
- tresmejores f lista = mayamen [(f xy,x) |xy@(x,y)<-lista]
- where
- mayamen = map snd.take 3.reverse.sort
- masde7:: Ayudante->Int
- masde7 (x,y) = (length.filter (>=7).map snd) y
- tema:: String->Ayudante->Int
- tema s (a,c) = cabeza [n|(t,n)<-c,t==s]
- where
- cabeza [] = 0 --si dicho tema no lo sabe el valor de puntuación es 0
- cabeza a = head a
- --b)
- --tresmejores (tema "ordenSuperior") ayudantes
- --["Cristian","Maria","Juan"]
Advertisement
Add Comment
Please, Sign In to add comment