Extending the prompt implementation scope
Until now, we have mainly worked with short functions spanning only a few lines of code, applying our best practices for prompt precision to generate effective code using GitHub Copilot, OpenAI, and ChatGPT.
However, in many real-world scenarios, our tasks will not fit within such a narrow scope. We may need to handle input casting, switch cases, or adapt implementations beyond a raw mathematical formula. This chapter explores how we can extend the scope of coding tasks by applying advanced prompt engineering techniques.
Extending the geometric mean scope
Let us revisit the geometric mean implementation from Chapter 3. The geometric mean is a method of averaging numbers that have a multiplicative nature, such as financial portfolio growth rates, population growth rates, or drug concentrations that change exponentially over time. The geometric mean is defined as the nth root of the product of the inputs, as follows:
For...