initial working prototype of the head/tail/some preset filter

This is an initial attempt at a working head/tail/some preset filter for gfilter(). The implementation is NOT yet ready to be included upstream. See discussion in issue #29 .