Message Boards Message Boards

3 Replies
2 Total Likes
View groups...
Share this post:

Isn't there any way put functions in a list?

Posted 9 years ago

I want to use a function like method in an OOP programming.

If there is a list which is named k, then I want to have a list like

k[[5]]["Hello, "]

The result I expect from the last input above is "Hello, Samy". The point is whether it is possible to deal with functions as elements in a list so that we can get the ability of OOP's method features.

Thanks. :)

POSTED BY: Dong Hyeon Ghang
3 Replies

There are number of ways to emulate OOP in Mathematica, if you search Mathematica stackexchange you'll find number of topics on this. Here is a small note on one method.

POSTED BY: Nasser M. Abbasi

Hello, There are several ways to do this. Here is one:

myPrint[x_] := "x = " <> ToString[x]
fs = {Sin, Cos, myPrint}
POSTED BY: W. Craig Carter

Thank you for help. Your answer helped me a lot.

There are many problems with this OOP-related-features in Mathematica. And one is solved due to your explanation. Have a Good day.

POSTED BY: Dong Hyeon Ghang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract