Function output

Function output - Messages

#1 Posted: 9/20/2009 1:11:06 PM
Greg Locock

Greg Locock

0 likes in 53 posts.

Group: User

Not to sure how it is coded, but would it be possible to explicitly state the output variable within a function.

For instance


func(a,b):=some complicated stuff which ends up in M
M=
#2 Posted: 9/20/2009 10:05:49 PM
Andrey Ivashov

Andrey Ivashov

2270 likes in 3734 posts.

Group: Super Administrator

Not sure I understand. Please, post detailed explanation, maybe I'll implement it.
#3 Posted: 9/21/2009 8:45:07 AM
Greg Locock

Greg Locock

0 likes in 53 posts.

Group: User

https://smath.com/wiki/GetFile.aspx?File=gregpics%5csunday_insert_problem.zip

for example. The procedure to insert a row works, but the function doesn't because you can't explixitly return the answer.

Something like ans:=B would be the way i'd expect to do it, where ans is a reserved word like in Matlab

#4 Posted: 9/21/2009 11:11:06 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Wrote

https://smath.com/wiki/GetFile.aspx?File=gregpics%5csunday_insert_problem.zip

for example. The procedure to insert a row works, but the function doesn't because you can't explixitly return the answer.

Something like ans:=B would be the way i'd expect to do it, where ans is a reserved word like in Matlab


This is, actually, the possibility to make Mathcad-like multiline functions with "line" (extension of SMath programing capability). It is on my "wishlist" as well. I really do not have the slightest idea how complicated could that be to implement in SMath, considering differences between SMath and Mathcad.

As far as I know (hope I am right) the only way to define a function in more then one line (just visually) is with "if":
[MATH]func(x)←if(x≤5;5;x)[/MATH]
[MATH]func(2)=5[/MATH]
[MATH]func(10)=10[/MATH]

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#5 Posted: 9/21/2009 11:36:03 AM
Greg Locock

Greg Locock

0 likes in 53 posts.

Group: User

other syntax suggestions, these would go as the last line in a multiline function

B=

return(

B

I don't really have a preference, although B= is probably a bit weird.

  • New Posts New Posts
  • No New Posts No New Posts