I am trying to write a function
row :: Int -> Int -> [Int]
row n v
which returns a list of nintegers, all 0', except for the vth element that should be 1.
For instance,
row 0 0 = []
row 5 1 = [1,0,0,0,0]
row 5 3 = [0,0,1,0,0]
I am new to Haskell and have great difficulty with this. In particular, I cannot figure out how to do the repetition 0. I understand the concept of building a list from let say [1..n], but I just get[1,2,3,4,5]
Any help with this would be greatly appreciated. Thank.
source
share