I want to get 2 integers from an input like pascal 2 1. This input should be 2, because the list starts with x and y = 0. Also pos must be <= row and i don't want to use guards. My code looks like this:
pascal :: Int -> Int -> Int
pascal row pos
if row == 0 || pos == 0 then "1"
else if row > pos then error "Invalid input."
else (pascal (row-1) (pos-1)) + (pascal (row-1) (pos))
Error code:
Unexpected if expression in function application:
if row == 0 || pos == 0 then
"1"
else
if row > pos then
error "Invalid input."
else
(pascal (row - 1) (pos - 1)) + (pascal (row - 1) (pos))
You could write it with parentheses
Or perhaps you meant to enable BlockArguments?