Re: Pass by Reference

new topic     » goto parent     » topic index » view thread      » older message » newer message
dcuny said...

I'm writing an application that has multiple digital filters. Calling the filter:

  • Calculates a filtered result, and
  • Updates the filter's history.

Euphoria 4.1 lets you do this:

include std/sequence.e 
include std/console.e 
 
function do_filter( sequence theFilter, atom theInput ) 
   atom theOutput = theFilter[1] * theFilter[2] * theInput 
   theFilter[2] = theFilter[1] 
   theFilter[1] = theInput 
 
   return { theFilter, theOutput } 
end function 
 
atom theInput = 1 
sequence theFilter = {2,3} 
atom theResult = 0 
 
 
        printf(1, "START\n\t input: %d", theInput ) 
        printf(1, "\n\t filter: %d %d", theFilter ) 
        printf(1, "\n\t result %d", theResult ) 
 
 
{ theFilter, theResult } = do_filter( theFilter, theInput ) 
 
 
        printf(1, "\n\nFINISH\n\t input: %d", theInput ) 
        printf(1, "\n\t filter: %d %d", theFilter ) 
        printf(1, "\n\t result %d", theResult ) 
 
--START 
--     input: 1 
--     filter: 2 3 
--     result 0 
-- 
--FINISH 
--     input: 1 
--     filter: 1 2 
--     result 6 

The idea is that in Euphoria you can always identify the exact line where an object changes its value.

_tom

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu