This portion of code checks if a number given (First element in a list) is zero (yes i tried == 0 but got other errors) It then return all elements of another list except the first one. If not, it returns another list. The function is of type [a] and 'newpack' needs to be a variable as it is used later.
if ((position!!1) < 1)
then
let newpack = drop ((length pack)-1) pack
else
let newpack = (take ((position!!1)-1) pack) ++ (drop ((position!!1)+1) pack)
error is 46:73: parse error on input `else'
Do have any idea why this is not working? Is it that'let's needs an 'in' with them?
Thanks for your help,
J
position !! 1yields the second element of the listposition(or a runtime error, if it is too short). Indices are 0-based.if a then b else cwitha? b : cin your mind. What imperative languages callifiswhenin Haskell (not available by default, you have to importControl.Monad), but you can't use that in this way either.