Haskell- Type matching -


i having trouble getting output helper function match output of function using code below:

getsemidiag :: [[maybe player]] -> int -> int -> [maybe player] getsemidiag [] _ _ = [] getsemidiag (x:xs) start size = if start > (size -1)                             []                             else (x !! start) : (getsemidiag xs (start+1) size)    semiright :: [[maybe player]] -> int -> int -> [[maybe player]] semiright [] _ _ = [] semiright (x:xs) start size = if start > (size -1)                           []                           else (getsemidiag x start size) : (semiright xs (start+1) size) 

the function semiright won't match despite best efforts. thoughts?

judging type, x matched element has type of [maybe player],

you should pass [x] not x getsemidiag. moreover, brackets redundant.

semiright :: [[maybe player]] -> int -> int -> [[maybe player]] semiright [] _ _ = [] semiright (x:xs) start size = if start > (size -1)                           []                           else getsemidiag [x] start size : semiright xs (start+1) size 

why not use zipwith

semiright players start size = zipwith (\p -> [p !! i]) players [start .. size] 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -