Soy un principiante y estoy tratando de hacer algunos tutoriales en Haskell antes de ingresar a la universidad Ciencias de la Computación.no pudo coincidir con el tipo esperado (Int -> Int -> Int) con el tipo real `(t0, t1, t2) '
Me quedé atrapado en este programa. Toma tres números y los pone en orden ascendente. ¿Puede alguien ayudarme y decirme qué pasa porque me está volviendo loco? Gracias por tu tiempo.
import Prelude hiding (min,max)
orderTriple :: (Int -> Int -> Int) -> (Int -> Int -> Int)
max :: Int -> Int -> Int -> Int
min :: Int -> Int -> Int -> Int
middle :: Int -> Int -> Int -> Int
max x y z
|(x>=y) && (x>=z) = x
|(y>=x) && (y>=z) = y
|otherwise = z
min d e f
|(d<=e) && (d<=f) = d
|(e<=d) && (e<=f) = e
|otherwise = f
middle g h i
| (g <= (max g h i)) && (g >= (min g h i)) = g
| (h <= (max g h i)) && (h >= (min g h i)) = h
| otherwise = i
orderTriple (a,b,c) = ((min a b c),(middle a b c),(max a b c))
El error es:
orderList.hs:23:13:
Couldn't match expected type `[Int -> Int -> Int]'
with actual type `(t0, t1, t2)'
In the pattern: (a, b, c)
In an equation for `orderTriple':
orderTriple (a, b, c) = [(min a b c), (middle a b c), (max a b c)]
¿En realidad va a estar haciendo Haskell (o algún tipo de FP) en la universidad? ¡Ojalá hubiera conseguido eso en mi programa! – MatrixFrog