Está en la página 1de 7

EJERCICIOS PROPUESTOS DE PARADIGMAS DE PROGRAMACION

PRESENTADO POR: JESUS ALFREDO MERCHAN


DANNY AGUILAR GIL

PRESENTADO A: JESUS ENRIQUE DURAN VILLAMIZAR

PARADIGMAS DE PROGRAMACION

UNIVERSIDAD DE PAMPLONA
FACULTAD DE INGENIERÍAS Y ARQUITECTURA
2020
Primera guia de ejrcicios

1)
module Calculos where

--ejercicio propuesto 1
z :: Fractional a => a -> a -> a -> a -> a
z a b c d = (a) / (b-c) + d

--ejercicio propueato 2
z2 :: Fractional a => a -> a -> a -> a -> a
z2 a b c d = (a) / (b-c+d)

--ejercicio propuesto 3
z3 :: Fractional a => a -> a -> a -> a -> a
z3 a n b c = (a-(5+n)) / (b+c)

2)
module Areas where

--punto 3
area_circulo :: Floating a => a -> a
area_circulo r = (pi*r)^2

area_triangulo :: Fractional a => a -> a -> a


area_triangulo b h = ((b*h)/2)

--area de hexagono regular area=perimetro * apotema /2 --area_hexagono_r 36 5.2


area_hexagono_r :: Fractional a => a -> a -> a
area_hexagono_r p a = (p*a) / 2

area_rectangulo b h = b*h

3)
module Distancia2puntos where
--punto4
dimension1 :: Num a => a -> a -> a
dimension1 a b = b-a

--Distancia entre dos puntos en 2 dimensiones (en un plano)


dimension2 :: Floating a => a -> a -> a -> a -> a
dimension2 x1 y1 x2 y2 = sqrt((x2-x1)^2+(y2-y1)^2)

--Distancia entre dos puntos en 3 dimensiones (en el espacio)


dimension3 :: Floating a => a -> a -> a -> a -> a -> a -> a
dimension3 x1 y1 z1 x2 y2 z2 = sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2)
f_suma x y = x + y
raizcuad x = sqrt (x)
raizcuadf_suma x y = raizcuad(f_suma x y)

5)
module Problema5 where

--Vc = l a h
problema x = (4*(x*x*x))-(54*(x*x))+(170*(x))

GUIA 2

module ComponeFunction where

division :: Int -> Int -> Int


division x y = div x y

cuadrado :: Int -> Int


cuadrado x = x*x

siguiente :: Num a => a -> a


siguiente x = (x+1)

triple :: Num a => a -> a


triple x = x*3
--3 * X
triple_siguiente :: Num a => a -> a
triple_siguiente x = triple (siguiente x)

siguiente_triple :: Num a => a -> a


siguiente_triple x = siguiente (triple x)

-- determinar si un numero es negativo


--sgn :: Int -> Bool
--sgn n| n > 0 = true
-- | n < 0 = false

prop_equivalencia :: Int -> Bool


prop_equivalencia x =
doble_2 x == doble_1 x &&
doble_3 x == doble_1 x

EJERCICIOS DE CONDICIONALES

module Condicionaless where

---------- @DANNYAGUILARGIL------------
---------_------UP----------_-----------
absoluto :: Int -> Int
absoluto n = if n>0 then n else n*(-1)

restap :: Int -> Int -> Int


restap a b = if a>b then a-b else b-a

letra :: Int -> Char


letra x = if x==5 then 'a' else 'b'

mayor :: Int -> Int -> Int


mayor x y = if x>y then x else y

sueldo :: Int -> Int


sueldo x = if x<900000 then 1200 else 2400

categoria :: Int -> Char


categoria x = if x<=450 then 'a' else 'b'

----------------------------------------------------
--modulo :: Int -> Int
modulo x = mod x 10
----------toma el ultimo digito del numero

codigo :: Int -> String


codigo x = if mod x 10<=4 then "Villa del rosario" else "Cucuta"

--notas :: Fractional a => a -> a -> a -> a


--notas n1 n2 n3 = n1*0.35+n2*0.35+n3*0.30
nota :: (Ord a, Fractional a) => a -> a -> a -> [Char]
nota n1 n2 n3 =if n1*0.35+n2*0.35+n3*0.30 >3 then "APRUEBA" else "REPRUEBA"

EJERCICIO CON CONDICIOANLES COMPUESTAS TALLER#3

--------------EJERCICIOS CON CONDICIONALES COMPUESTAS----------------------


taekondo :: (Ord a1, Ord a, Num a1, Num a) => a1 -> a -> [Char]
taekondo edad promedio = if edad>10 && promedio>=8 && promedio <=10 then "PUEDE
PERTENER AL EQUIPO DE TAEKWONDO" else "NO CUMPLES CON LOS REQUISITOS"

module Condicional_compuestas where

--primero divido entre 10 y luego saco el modulo 10


--EJERCICIO 2 DE CONDICIONALES COMPUESTAS
--SACA EL MODULO DE UNA DIVISION PARA TOMAR NUMERO DE LA MITAD
modulo x2 = mod x2 10 --toma ultima cifra
divide :: Int -> Int -> Int
divide x y = div x y -- DIVIDO ENTRE 10 PARA TOMAR EL NUMERO DE LA MITAD ej 543 10
modulo_div :: Int -> Int -> [Char]
modulo_div x y = if modulo (divide x y)>=5 && modulo (divide x y)<=7
then "NO ES DEFECTUOSO" else "ES DEFECTUOSO"

---------------------------------------------------------------------
bisiesto :: Integral a => a -> [Char]
bisiesto x = if mod x 4==0 && mod x 100==0 || mod x 400==0 then "ES BISIESTO" else "NO ES
BISIESTO"

producto :: (Ord a, Num a) => a -> [Char]


producto c = if c>=15 && c<=40 || c>=75 && c<=85 then "se vende con descuento" else "no se vende
con descuento"

nota_def :: (Ord a, Fractional a) => a -> [Char]


nota_def x = if x>=4.5 && x<=4.9 then "NOTABLE" else "NO ES NOTABLE"

anidamiento :: (Num a, Ord a) => a -> [Char]


anidamiento x = if x==0 then "Ingreso un cero" else if x>0 then "Ingreso un valor positivo"
else "usted ingreso un valor negativo"

mayor :: Ord a => a -> a -> a -> a


mayor a b c = if a>b && a>c then a else if b>a && b>c then b
else c

pago :: (Ord a, Num a) => a -> [Char]


pago s = if s<900000 then "la cuota es de 900" else if s<1500000 then "la cuota es de 1300"
else "la cuota es de 2400"

categoria c = if c<=450 then "categoria a" else if c<=700 then "categoria b"
else "categoria c"

codigo x2 = if mod x2 10>=1 && x2<=3 then "Pertenece a la sede villa del rosario"
else if mod x2 10==5 then "Pertenece a la sede cucuta"
else if mod x2 10==6 then "Pertenece a la sede cucuta"
else if mod x2 10>=7 then "Pertenece a la sede pamplona"
else if mod x2 10==0 then "Pertenece a la sede pamplona"
else "no pertenece a ninguna sede"

--nota :: (Ord a, Fractional a) => a -> a -> a -> [Char]


nota n1 n2 n3 =if n1*0.35+n2*0.35+n3*0.30 >3 then "APROBO LA ASIGNATURA"
else if n1*0.35+n2*0.35+n3*0.30>=2.0 &&
n1*0.35+n2*0.35+n3*0.30<=2.9 then "EL ESTUDIANTE PUEDE HABILITAR"
else "EL ESTUDIANTE REPROBO LA ASIGNATURA"

cuadrado :: Int -> Int


cuadrado x = x * x
cuadrado_modulo x = cuadrado x
EJERCICIOS CON GUARDAS TALLER#3
--PDF EJERCICIOS CONDICIONALES CON HASKELL

absoluto2 :: Int -> Int


absoluto2 n | n>0 = n
| otherwise = n*(-1)

restap2 :: Int -> Int ->Int


restap2 a b | a>b = a-b
| otherwise = b-a

letra2 :: Int -> Char


letra2 x | x==5 = 'a'
| otherwise = 'b'

tarifa est nc | est==1 && nc<=10 =5000


| est==1 && nc>=10 =5000+(nc-10)*800
| est==2 && nc<=25 =10000
| est==2 && nc>25 =10000+(nc-25)*800

mediano :: Int -> Int -> Int -> Int


mediano x y z | x==3 && y==2 && z==5 =3
| x==2 && y==4 && z==5 =4
| x==2 && y==6 && z==5 =5
| x==2 && y==6 && z==6 =6

imc :: Float -> String


imc p | p <=18.5 = "Tienes infrapeso"
| p <=25.0 = "Eres normal"
| p <=30.0 = "tienes sobrepeso"
| otherwise = "estas obeso"

imc_calc :: Float -> Float -> String


imc_calc p h | p / h ^2<=18.5 ="Tienes infrapeso"
| p / h ^2<=25.0 ="eres normal"
| p / h ^2<=30.0 ="tienes sobrepeso"
| otherwise = "estas obeso"

funcion :: Int -> Int


funcion x | x<=(-5) =x
| x<=5 || x<=(-5) =x+3
| x>=5 =x^2-2

--imc_calc :: Float -> Float -> String


--imc_calc pe a | bmi<=s ="Tienes infrapeso"
-- | bmi<=n ="eres normal"
-- | bmi<=f ="tienes sobrepeso"
-- | otherwise = "estas obeso"
-- where bmi = pe / a^2
-- s=18.5
-- n=25.0
-- f=30.0
imc_calculo :: (RealFloat a) => a -> a -> String
imc_calculo a p | bmi <= 18.5 = "Tienes infrapeso Eres emo?"
| bmi <= 25.0 = "Supuestamente eres normal... Espero que seas feo."
| bmi <= 30.0 = "¡Estás gordo! Pierde algo de peso gordito."
| otherwise = "¡Enhorabuena, eres una ballena!"
where bmi = a / p ^ 2

bmiTell :: (RealFloat a) => a -> a -> String


bmiTell weight height
| bmi <= skinny = "Tienes infrapeso ¿Eres emo?"
| bmi <= normal = "Supuestamente eres normal... Espero que seas feo."
| bmi <= fat = "¡Estás gordo! Pierde algo de peso gordito."
| otherwise = "¡Enhorabuena, eres una ballena!"
where bmi = weight / height ^ 2
skinny = 18.5
normal = 25.0
fat = 30.0

bodegas c_dc th t | c_dc==1 && th==1 && t<10 =10000*t


| c_dc==1 && th==1 && t>=10 =7000*t
| c_dc==1 && th==2 && t<10 =50000*t
| c_dc==1 && th==2 && t==10 =50000*t
| c_dc==1 && th==2 && t>10 =50000*t+5000-5000
| c_dc==2 && th<2 && t<=4 =0
| c_dc==2 && th>2 && t<=4 =t*25/100+2000*th

También podría gustarte