Indentation error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
buildTable :: Int -> Int -> (Int -> Int -> a) -> [[a]]
buildTable n m fun = [[ fun x y 
                    | x <- [0..n-1]]
                    | y <- [0..m-1]]
lookupAns :: Int -> Int -> [[Int]] -> Int
lookupAns len1 len2 theArray = 
    theArray !! len1 !! len2


lcsLength :: String -> String -> Int
lcsLength s1 s2 =   let 
        n1 = length s1
        n2 = length s2
        table = buildTable (n1 n2 lcsHelp)

        lcsHelp = if ( n1 == 0 || n2 == 0 )
                     then 0
                  else if ( last s1 == last s2 )
                     then                    
                         (lookupAns (n1 - 1) n2 table) + 1
                  else
                         max (lookupAns n1 (n2-1) table) (lookupAns (n1-1) n2 table)
        in lookupAns
           (length s1)
           (length s2)
           table
16:9: Warning: Use guards
Found:
lcsHelp
= if (n1 == 0 || n2 == 0) then 0 else
if (last s1 == last s2) then (lookupAns (n1 - 1) n2 table) + 1 else
max (lookupAns n1 (n2 - 1) table) (lookupAns (n1 - 1) n2 table)
Why not:
lcsHelp
| (n1 == 0 || n2 == 0) = 0
| (last s1 == last s2) = (lookupAns (n1 - 1) n2 table) + 1
| otherwise =
max (lookupAns n1 (n2 - 1) table) (lookupAns (n1 - 1) n2 table)
16:19: Warning: Redundant bracket
Found:
if (n1 == 0 || n2 == 0) then 0 else
if (last s1 == last s2) then (lookupAns (n1 - 1) n2 table) + 1 else
max (lookupAns n1 (n2 - 1) table) (lookupAns (n1 - 1) n2 table)
Why not:
if n1 == 0 || n2 == 0 then 0 else
if (last s1 == last s2) then (lookupAns (n1 - 1) n2 table) + 1 else
max (lookupAns n1 (n2 - 1) table) (lookupAns (n1 - 1) n2 table)
18:24: Warning: Redundant bracket
Found:
if (last s1 == last s2) then (lookupAns (n1 - 1) n2 table) + 1 else
max (lookupAns n1 (n2 - 1) table) (lookupAns (n1 - 1) n2 table)
Why not:
if last s1 == last s2 then (lookupAns (n1 - 1) n2 table) + 1 else
max (lookupAns n1 (n2 - 1) table) (lookupAns (n1 - 1) n2 table)
20:26: Warning: Redundant bracket
Found:
(lookupAns (n1 - 1) n2 table) + 1
Why not:
lookupAns (n1 - 1) n2 table + 1