delegate usage and new "constructs"

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

delegate usage and creating new "constructs"
when it's integrated better with the language, it allows a high level of abstraction and usually more concise code...
just something to think of.

here is one example:

-- count.ex 
 
function count(sequence seq, sequence predicate_funcname, object findme) 
   integer count = 0 
   integer func = routine_id(predicate_funcname) 
    for i = 1 to length(seq) do 
        if call_func(func, {seq[i], findme}) then  
            count += 1 
        end if 
    end for 
    return count 
end function 
 
function rem(object a, object b) 
    return remainder(a,b) = 0 -- or could be: a contains b, etc.. 
end function  
 
 
? count({1,2,3,4,5,6,7,8,9,10}, "rem",3) 
-- (the result is 3) 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu