I'm developing a data processing pipeline "factory". In order to think, organize, and search about the computation components it would be useful to have some concepts and vocabulary to characterize and classify functions based on characteristics of their inputs and/or outputs.
Otherwise put, I'm looking for a vocabulary to develop a taxonomy of functional design patterns.
I'll list some of my own notes, as a matter of example, but feel that there's probably well established ways of describing functional patterns.
For example, I can characterize functions based on the number of inputs and outputs
- simple function: Single input and output
- sink: function with no output (or null output)
The nature or kind of their inputs or outputs:
- sequencers: Functions that take a sequence/stream as an input
- boolean: functions that return True or False
Some characteristic/feature of what the function does with the input (or relationship between input and output):
- sorter: takes a sequence of items and outputs a sequence of the same size, but arranged in a specific manner
- filter: takes an sequence of items and outputs a subsequences, e.g.
positive_numbers_only([1,-2,3,-4,3]) -> [1,3,3]
) - filter_decider: takes a single output and outputs a boolean (interpreted as take/do_not_take, e.g.
is_positive(x) -> x>0
) - flattener: takes a nested structure and outputs a flat version of the same, without loosing any information (example
[[1,2,3],[4,5]] -> [1,2,3,4,5]
) - aggregator: takes a sequence and outputs an object that involved every element of the sequence, but with a reduction of information (example,
sum
,mean
,unique_values
...)
Aucun commentaire:
Enregistrer un commentaire