In languages where functions really are first class, such as clojure, you might write something like:
(apply comp functions) To create a new function that is the combined function of encrypt and compress.
The step before this to actually make the choice would then be any normal sort of filtering. Say:
(def funcs { :encrypt (fn [data] ... ) :compress (fn [data] ... )}) ... (defn do-processing [options data] (let [funcs-to-run-here (map options funcs) ;filters out the only relevant functions combined-in-one-func (apply comp funcs-to-run-here)] ;create single function (combined-in-one-func data))) ;apply it For the non-clojure viewer: funcs is defined as a lookup map. :encrypt is a keyword, here you can just view it as a enum, and is the key. The value is the function.
The only thing needed now would be to call it with the options
(do-processing [:encrypt :compress] data) And to extend it, you would add rows in the funcs map.