Created
September 17, 2013 20:28
-
-
Save Pranz/6600109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void filterM(bool (*f)(void*), List *ls){ | |
List *xs = ls | |
while !f(xs->head) { | |
free(xs) | |
xs = xs->tail; | |
} | |
List *prev_node = xs; | |
for(List *i = xs->tail; i != NIL; i = i->tail){ | |
if !f(i->head) { | |
free(i); | |
prev_node->tail = i->tail; | |
} | |
else prev_node = i; | |
} | |
return xs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment