Click here to Skip to main content
15,904,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to access a list within a list using recursion. For example : you have as an input [[1,2], [2, 3]] and I trying to access every element within that input as taking the head [1,2] and now I would like to access 1 and after 2.

What I have tried:

I have tried the following:

function_name input
| [x:xs] <- head input, condition (x > 2) = function_name (tail input)
| otherwise = function_name(tail input)

Any other tips or models to solve this?
Posted
Comments
CPallini 6-Feb-16 15:31pm    
Sorry, I cannot understand what your requirement is. Could you please give more details?
Member 12311139 7-Feb-16 2:35am    
Yes, so you give an input as [[1,2], [2,3], [4,5], [1,1]] and I would like to check each element within the list to see if it is >2 . (My problem is that I don't know how to access a list within a list. I tried a recursive version above (for a general aspect). Output[3,4,5]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900