Assuming I have a list like this
let a =[["Warning:","Route","1543","must","Stop","on","Link","11881"],["Warning:","Route","1578","must","Stop","on","Link","12171"]]
And I want to extract third element of each list inside it, i.e I want to get the resultant as ["1543","1578"]
I wrote the following piece of code for obtaining it, but it is not working:
foldr (\acc x -> (x !! 2):acc) [] a
map (!! 2)would sufficefoldrworks too, but it requires other order of arguments:foldr (\x acc -> (x !! 2):acc) [] a.Maybeis a more safer choice.datatype and write a nice parser with e.g. parsec – but it would probably be overkill; if this is just for a one-time script thenmap (!! 2)is positively fine.