I think the simple examples serve to show the syntax only, and do not explain 
its utility.
The nested function definition will be useful if called many times within a 
lengthy function, or just for sake of code clarity.

Regards,
Rafael

-----Original Message-----
From: users <[email protected]> On Behalf Of Izabela Wójcik-Grzaba
Sent: Wednesday, April 10, 2019 5:04 PM
To: Users mailing list for Scilab <[email protected]>
Subject: Re: [Scilab-users] Nested function definition

Ok, so why nested function in help is so complicated:

//nested functions definition
function y=foo(x)
    a=sin(x)
    function y=sq(x), y=x^2,endfunction
    y=sq(a)+1
endfunction

foo(%pi/3)

Couldn't it be formulated like below:

function y1=foo1(x)
    a=sin(x);
    y1=a^2+1;
endfunction

foo1(%pi/3)

That's why I had problems with my functions and couldn't understand why it has 
to be so complicated.

Thank you once more.

Iza

_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to