| OCR Text |
Show 93 i . Recursion Recursion is easy in the FLEX environment. Each parent process simply creates a new child which is linked to the patent by the returns. The | call | operator is used so that juat one instance of the recursion is active at any one time« Following is a subroutine which calls itself for . determining the factorial of a number. fact ♦ 'new a. if a -■ 1 then 1 else a * fact (a-1) ' ; '"This creates the following structures when activated by the next statement11' display - "fact (3) = "#fact (3); fact. (3) =6.0 .4. . parent 1st instance N 2 N "2 ! ''/' j' " ■"" I , 2nd instance LEi 'Ni 1 "T 3rd instance Reproduced from I best available copy. All returns from a call as well as reactivating the parent process also transfer the top element in t*ie stack from the returned process to the top element in the stack of the parent process. This ^ the way results are passed back when a procedure is used as a function. |