场景是这样的:
有一种算法称为alg1,另一种算法称为alg2。
还有一个名为 的入口函数solve,如何传递alg1来求解然后我可以使用alg1进行计算,并传递alg2来使用alg2进行计算?
solve(a, b, alg1) #return the results computed with alg1
solve(a, b, alg2) #return the results computed with alg2
Run Code Online (Sandbox Code Playgroud)
我需要将算法编写为函数吗?