filtering directly and indirectly connected things from list
- by Andreas Romeyke
Hello,
if you have a function "test a b" which returns true if a and b are connected directly and if you have a given unordered list of things, what would be an elegant and fast solution to filter all connected things from given list?
Example:
let test a b = let diff = a - b in diff == 0 ;;
let lst = [4;1;7;3;8;9;2;0] ;;
filter_connected 2 lst ;;
- [4;1;3;2;0]
Any hints?