Skip to content

Instantly share code, notes, and snippets.

@Pranz
Created September 17, 2013 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pranz/6600109 to your computer and use it in GitHub Desktop.
Save Pranz/6600109 to your computer and use it in GitHub Desktop.
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