Function output

Function output - Сообщения

#1 Опубликовано: 20.09.2009 13:11:06
Greg Locock

Greg Locock

0 сообщений из 53 понравились пользователям.

Группа: 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 Опубликовано: 20.09.2009 22:05:49
Andrey Ivashov

Andrey Ivashov

2269 сообщений из 3729 понравились пользователям.

Группа: Super Administrator

Not sure I understand. Please, post detailed explanation, maybe I'll implement it.
#3 Опубликовано: 21.09.2009 08:45:07
Greg Locock

Greg Locock

0 сообщений из 53 понравились пользователям.

Группа: 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 Опубликовано: 21.09.2009 11:11:06
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: 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 Опубликовано: 21.09.2009 11:36:03
Greg Locock

Greg Locock

0 сообщений из 53 понравились пользователям.

Группа: 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.

  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений