lundi 23 septembre 2019

Struggling with parsing if statements and code layout in Haskell

The code here is nonsense and I know it, I don't want a different solution to this problem because this is just to highlight my issue not the actual goal. This is my code:

example x
    if x == 2 then "Input is 2"
        else if x > 2 then if x == 3 then "Input is 3"
                else "Input is greater than 3"
            else "Dunno"
        else "Dunno"

My intended input -> output is: [0, 1, 2, 3, 4] -> ["Dunno", "Dunno", "Input is 2", "Input is 3", "Input is greater than 3"]

I'm having a hard time getting started with Haskell I'm finding the formatting of if's and else a lot less intuitive than python.

Aucun commentaire:

Enregistrer un commentaire