Functional programming primitives and abstractions for narrowband level sets