Diferencia entre revisiones de «Primer Parcial 1er Cuat 2016 (Paradigmas)»

De Cuba-Wiki
(Página creada con «{{Back|Paradigmas de Lenguajes de Programación}} === Ejercicio 1 === a) foldfs :: b -> (Nombre -> b -> b) -> (Nombre -> b -> b -> b) -> Filesystem -> b foldfs fvacio fa...»)
 
 
Línea 21: Línea 21:
  arosetrees = foldfs [] (\s b -> (Rose s []) : b) (\s b1 b2 -> (Rose s b1):b2)
  arosetrees = foldfs [] (\s b -> (Rose s []) : b) (\s b1 b2 -> (Rose s b1):b2)
   
   
  arosetree :: Filsystem -> Rosetree Nombre
  arosetree :: Filesystem -> Rosetree Nombre
  arosetree = Rose '/' arosetrees
  arosetree = Rose '/' arosetrees



Revisión actual - 16:29 13 jul 2019

Plantilla:Back

Ejercicio 1[editar]

a)

foldfs :: b -> (Nombre -> b -> b) -> (Nombre -> b -> b -> b) -> Filesystem -> b
foldfs fvacio farchivo fcarpeta fs =
    case fs of vacio -> fvacio
               archivo n fs -> farchivo n (rec fs)
               carpeta n fsc fss -> fcarpeta n (rec fsc) (rec fss)
                   where rec = foldfs fvacio farchivo fcarpeta

b)

listado :: [Nombre]
listado = foldfs [] (:) (\s l1 l2 -> s:l2)

c)

rutasdearchivo :: Nombre -> Filesystem -> [Nombre]
rutasdearchivo n = foldfs [] (\s p -> if s==n then '/':n++p else p) (\c p1 p2 -> (map (\s -> '/':c++s) p1) ++ p2)

d)

arosetrees :: Filesystem -> [Rosetree Nombre]
arosetrees = foldfs [] (\s b -> (Rose s []) : b) (\s b1 b2 -> (Rose s b1):b2)

arosetree :: Filesystem -> Rosetree Nombre
arosetree = Rose '/' arosetrees

Ejercicio 2[editar]

a) Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \frac{\Gamma \triangleright M: \sigma}{Matriz(M): Matrizinfinita_\sigma}T-Def}

Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \frac{\Gamma \triangleright M: Matrizinfinita_\sigma \;\;\; \Gamma \triangleright N: Nat \;\;\; \Gamma \triangleright O: Nat \;\;\; \Gamma \triangleright P: \sigma}{\Gamma \triangleright M[N][O] \leftarrow P :: Matrizinfinita_\sigma} T-Asig }

Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \frac{\Gamma \triangleright M: Matrizinfinita_\sigma \;\;\; \Gamma \triangleright N: Nat \;\;\; \Gamma \triangleright O: Nat}{\Gamma \triangleright M[N][O] :: \sigma}T-Obs}

b) Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \dfrac{ \dfrac{ \dfrac{ \dfrac {f:Bool \rightarrow Bool \in \{f:Bool \rightarrow Bool\}} {\{f:Bool \rightarrow Bool\} \triangleright f:Bool \rightarrow Bool} T-Var }{\{f:Bool \rightarrow Bool\} \triangleright Matriz(f):Matrizinfinita_{Bool \rightarrow Bool}} T-Def \;\;\; \dfrac{\dfrac{ } {\{f:Bool \rightarrow Bool\} \triangleright 0:Nat} T-Zero} {\{f:Bool \rightarrow Bool\} \triangleright succ(0):Nat} T-Succ \;\;\; \dfrac{ } {\{f:Bool \rightarrow Bool\} \triangleright 0:Nat} T-Zero \;\;\; \dfrac{ \dfrac{ } {\{f:Bool \rightarrow Bool, x:Bool\} \triangleright true:Bool} T-True } {\{f:Bool \rightarrow Bool\} \triangleright \lambda x:Bool.true:Bool \rightarrow Bool} T-Abs }{\{f:Bool \rightarrow Bool\} \triangleright Matriz(f)[succ(0)][0] \leftarrow (\lambda x:Bool.true):Matrizinfinita_{Bool \rightarrow Bool}} T-Asig \;\;\; \dfrac{ } {\{f:Bool \rightarrow Bool\} \triangleright 0:Nat} T-Zero \;\;\; \dfrac{\dfrac{ } {\{f:Bool \rightarrow Bool\} \triangleright 0:Nat} T-Zero} {\{f:Bool \rightarrow Bool\} \triangleright succ(0):Nat} T-Succ } { \{f:Bool \rightarrow Bool\} \triangleright Matriz(f)[succ(0)][0] \leftarrow (\lambda x:Bool.true) [0][succ(0)]:Bool \rightarrow Bool } T-Obs }