instrucciones basicas
DESCRIPTION
fernando y yandiraTRANSCRIPT
INSTRUCCIONES BÁSICAS
INSTRUCCIONES BÁSICAS DE HASKELL
Type: Type: Permite renombrar tipos (no crea nuevos tipos)
Data: Data: Se crean nuevos tipos de datos mediante el uso de constructores.
La forma de introducir nuevos tipos es a través de las INSTRUCCIONES:
INSTRUCCIONES BÁSICAS DE HASKELL
La declaración type simplemente hace un renombramiento, pero no introduce nuevos tipos de datos.
Ejemplo: Transformar las coordenadas de un punto 2D.transPunto:: (Int ,Int) -> (Int,Int)transPunto (x,y) = ....
Se puede renombrar la tupla (Int,Int) con un solo identificador, por ejemplo: Coordenadas.
INSTRUCCIONES BÁSICAS DE HASKELL
En Haskell
type Coordenadas = (Int, Int)
transPunto:: Coordenadas -> Coordenadas
transPunto (x, y) = (y,x)
INSTRUCCIONES BÁSICAS DE HASKELL
La instrucción data permite crear nuevos tipos de datos.
Ejemplo:data PALO = Oros|Copas|Espadas|Bastosdata FIGURA = As|Dos|Tres|Cuatro|Cinco|
Seis|Siete|Sota|Caballo|Rey
Con estas instrucciones se define en Haskell un nuevo tipo de datos que identifica a los palos y figuras de la baraja española.
INSTRUCCIONES BÁSICAS DE HASKELL
INSTRUCCIONES BÁSICAS DE HASKELL
GRACIAS