Re: Nested functions - better example?

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

I got lost in your Rosetta example "Nested Function"

How about:

function makeList( sequence item,  string separator=". "  ) 
 
            function makeItem( integer count, string separator, string element ) 
                return  sprintf( "%d%s%s", {count,separator,element} ) 
            end function 
 
    for i=1 to length(item) do 
        item[i] = makeItem( i, separator, item[i] ) 
        end for 
 
    return item 
    end function 
 
? makeList( {"first","second","third"} ) 
 
--> {"1. first","2. second","3. third"} 

Used stuff like this in Pascal in the olden days.

be well
_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu