Message Boards Message Boards

0
|
4478 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Dynamically create a list of anonymous functions?

Posted 6 years ago

As the title indicates, if you know how to create a list of anonymous functions in your program, please tell me.

POSTED BY: satoshi nakagawa
6 Replies

The explanation of the previous article may have been difficult to understand.
I just wanted to dynamically generate multiple anonymous functions and pass them to Plot [] to compare the graphs.
Can this simple thing be written in mathematica?
Thank you.

POSTED BY: satoshi nakagawa

Sorry. I am Japanese.
I am using "Google Translate" because I can not write English directly.
Using "Google Translate" often causes "I" and "You" to overturn.

You can associate ... -> I can associate ...

I apologize to you for a fuss over.

POSTED BY: satoshi nakagawa

@satoshi nakagawa, please read our post above carefully. We are talking NOT about your text, but how you work with CODE on this forum. Please follow proper rules of writing and editing posts.

POSTED BY: Moderation Team

@satoshi nakagawa

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

enter image description here

POSTED BY: Moderation Team

Thank you very much. I also looked it up and found a function called ToExpression [].
When I normally evaluate ToExpression [{"# &", "# ^ 2 &", "Sqrt [#] &"}]
{# 1 &, # 1 \ ^ 2 &, Sqrt [# 1] &}
Actually, I want to link the value of the local variable in another built-in function to the list of this function, but this can not be done at all.
actually,
Plot [Evaluate [Table [Normal [Series [Sin [x], {x, n, 6}]], {n, 3, 3}]], {x, 0, Pi}]
I would like x and n to work with the Series arguments.
Table [] lists functions generated by multiple Series [].

After listing anonymous functions,
Plot [{Function [x, x ^ 2] [x], Function [x, x ^ 3] [x]}, {x, 0, 5}]
You can associate with x of Plot [] by attaching [x] after an anonymous function.
But, I do not know how to add [x] to the list of anonymous functions and interlock with x of Plot [].

Thank you.

POSTED BY: satoshi nakagawa

The question is a bit vague/broad, but here's one way:

ClearAll[powerfns];
powerfns[powers : {_?NumericQ ..}] := Function /@ (#^powers);

powerfns[{1, 2, 1/2}]

(*  {#1 &, #1^2 &, Sqrt[#1] &}  *)
POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract