5.2 Early terminated iterative operation
5.1 Simple iterative operations
Use the binary search to find the solution of lnx+2x-6=0 in the interval [0,3].
SPL
A | B | |
---|---|---|
1 | 1E-6 | |
2 | =y=1,1000.iterate((x=(~~(1)+~~(2))/2,y=ln(x)+2*x-6,if(y>0,[~~(1),x],[x,~~(2)])),[0,3],abs(y)<A1) | /Binary search |
3 | =x | /2.534919261932373 |
The ierate(x,a,c) is the iterative function with termination condition. In this function, c is the condition for terminating iteration.
Like common loop functions, we can define variables inside this function. The iteration termination condition set here is |lnx+2x-6|<1E-6.
SQL
SQL doesn’t provide a similar method.
Python
Python doesn’t provide a similar method.
5.3 Iteration in groups
Example codes for comparing SPL, SQL, and Python
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL