2

How to declare a parameter as function that can have 2 or 3 parameters in Haskell?

I have to make a repetir Function that allows to replicate any function, but we do have functions with 1 parameter and others with 2, so repetir won't work with 1-parameter functions as how is defined rigth now.

sacar :: Bolita -> Tablero -> Tablero
sacar bolita miTablero = accionarEnCelda bolita miTablero restarBolita

obtenerIndice :: (Int,Int) -> Int
obtenerIndice coordenadas = fst coordenadas * 3 + snd coordenadas

repetir :: (a -> b -> c) -> Int -> Tablero -> Tablero
JFMR
  • 23,265
  • 4
  • 52
  • 76
87nsilva
  • 33
  • 6
  • Please make your best attempt at formatting any post on StackExchange to be well-readable and expressing you intent. [Reading the Markdown reference](https://daringfireball.net/projects/markdown/syntax) is a good starting point, but I also mean things like adhering to the syntax rules of the language in questions (Haskell functions can't start uppercase like `Repetir`). Also, having long, non-English variable names isn't exactly helpful either. – leftaroundabout May 23 '23 at 19:15
  • 1
    What do you mean, "replicate"? What exactly is `repetir` supposed to do? – chepner May 23 '23 at 19:36

0 Answers0