Rank: Administration Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member Joined: 11/07/2008(UTC) Posts: 1,616 Was thanked: 1978 time(s) in 666 post(s)
|
24.02.2010omorr wrote:just for the curiosity, tell me what are your plans concerning multiline functions and functions as function arguments, or some other kind of this ability. Very often I wish that was implemented in SMath (I commented these things on an "brainstorming" topic on the Forum ).I would just like to know what are your plans about it, nothing else. smath wrote:Regarding multiline functions. I also see, that this should be implemented to extend abilities to create functions and I plan to implement it near time. Functions as function arguments not in my asap list, because I have no ideas of how to do this... I mean, that one of the important differences between Mathcad and SMath Studio is that functions and variables can be specified with the same names without covering: According to this, I don't know how to enable this functionality... But I believe it possible, so if I'll understand how, I'll do. omorr wrote:Yes, you are quite right. I was thinking about that but did not mentioned. I did not have any idea yet how to distinguish the function arguments,actually - how to make the difference between the variable and function name. I thought that the inclusion of text variables might lead to the solution. Then the problem would be how to distinguish the text constant from the function. I do not know? Is there any possibility to have something like: Code:x:=5
y:=6
g(a,b):=a+sin(b)
f(x,y,h(x,y)):=x+y+h(x,y)
result:=f(x,y,g(x,y))
or Code:x:=5
y:=6
g(a,b):=a+sin(b)
f(x,y,"fun h(2)"):=x+y+h(x,y)
result:=f(x,y,"fun g(2)")
Which means everything after "fun" (or something like that) must be a function name with number of arguments in parenthesis. I do not think this could be implemented, but I believe you will find the best way. Concerning functions, the SMath way gives improved functionality and greater flexibility comparing to Mathcad. I believe you will find the way to include functions as function arguments and multiline function. smath wrote:Great ideas! Not sure about using text to define functions in arguments, but the first variant is rather interesting! Also, I've combined both solutions you have mentioned and got this: Code:x:=5
y:=6
g(a,b):=a+sin(b)
f(x,y,h(2)):=x+y+h(x,y)
result:=f(x,y,g(x,y))
I think it is better, because f(x,y,h(x,y)) will cause misunderstandings about arguments (can we use the same arguments within main function's arguments and within the sub-function? If yes, then programs logic should be more complex, because in that case same names don't mean the same variables (?), otherwise constraints should be added (actually, I don't like constraints )). As I see, f(x,y,h(2)) also has some negative sides (mostly because f(2) looks like we try to evaluate function f using argument 2). Will think about this... omorr wrote:I am glad that I could be of any help. Your solution is very interesting. I am also not sure about it but I think that when you define a function like: f(x,y,h(2)):= you might use something else to note that this particular function has two arguments. Something not to be confused with calling the function with a constant, say f(x,y,h(2args)):= f(x,y,h(_2_)):= f(x,y,h(%2)):= whatever you find it suitable, do not know. After that, the possibility of calling the function with: result:=f(x,y,g(x,y)) is great 24.02.2010omorr wrote:On my second thoughts, this might be the best solution . Fictive arguments in the function definition are declared fine and understandable: f(x,y,h(2)):=Because this is a function definition, hardly we can be confused. Fictive argument which contains (n) after its name, where n is an integer, could be a function with n fictive arguments. Anything else is a variable (numerical or symbolical). I might be wrong of course not seeing any other nagative sides, but the function arguments are not evaluated i.e. there could not be an expression as a function argument. 23.10.2010smath wrote:I remember about functions as function arguments and couple of days ago I started to implement it but have a problem - I still can't find a best way how to represent this feature for user. It's good enough for me, if definition for such functions will be: f(g(2);c)←g(1;2)+cbut I not really like the ways I see how this definitions can be used: - g(a,←a*sqrt(
f(g(a;;3)=#
- f(el(x;1)*sqrt(el(x;2));3)=#
- f(function(a*sqrt(;a;;3)=#
I think that all this variants is not user-friendly enough. The most acceptable way, of course, is the first one, but it requires separate definition of the function before using it in argument... Maybe I don't see anything simplest? ... If we will understand how make it possible for user, I promise, I will implement it as soon as I can. This days I have a time and possibilities to do this work. Edited by user 24 June 2010 14:30:53(UTC)
| Reason: Not specified
|