I have 2 list:
["asd", "dsa"].
[[123, "asd"], [4534, "fgh"]].
How can i generate next list: I ned list that tail of each nested list =:= other element of 1 list.
In this example:
["asd", "dsa"].
[[123, "asd"], [4534, "fgh"]].
"asd" =:= "asd" ->
Output list:
[123, "asd"]
I try:
Here S = [[123, "asd"], [4534, "fgh"]]. D = ["asd", "dsa"].
List = lists:filter(fun(X) -> lists:last(X) =:= D end, S),
But D in this example list, and i need element of list.
How can do it?
Maybe something like:
1> [X || X<-[[1,2,4],[7,8,3],[2,5,4],[9,1,6]], Y<-[4,3], lists:last(X)=:=Y].
[[1,2,4],[7,8,3],[2,5,4]]
Or, using your sample data:
2> [X || X<-[[123,"asd"], [4534,"fgh"]], Y<-["asd","dsa"], lists:last(X)=:=Y].
[[123,"asd"]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With