Message Boards Message Boards

0
|
6916 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Beginner using CloudDeploy[FormFunction[]]

Posted 9 years ago

Hello!

I am a math teacher. Below is my code to just output a graph of any function. Unfortunately, it is only outputting a blank Cartesian grid. Any help would be sincerely appreciated. Thank you all!

CloudDeploy[FormFunction[{"equation" -> "MathExpression"}, Plot[ #equation, {x, -10, 10}]&, "PNG" ]]

PS. I halfway blindly copied this, and have no idea what the & does; just that it breaks without it.

POSTED BY: Uzair Qarni
5 Replies

I would start by making graphs and similar things. CloudDeploy and FormFunction are useful once you've learned the basics of the language.

I would take a look at the virtual book for an introduction:

http://reference.wolfram.com/language/tutorial/VirtualBookOverview.html

There are more resources in books and videos you might find helpful:

https://www.wolfram.com/broadcast/screencasts/handsonstart/

POSTED BY: Sean Clarke
Posted 9 years ago

Thank you for your responses! And Sean that's AWESOME thanks!!! I used the following example from the intro video:

CloudDeploy[FormFunction[{"size" -> "Number"}, Style["Hello World", Red, #size]&, "GIF"]]

It seems I underestimated the complexity of what I was getting into!

Some background: I currently spend a lot of time using Mac's Grapher and Screen capture to make my own worksheets. My ultimate goal is to automate making worksheets and multiple choice tests (i.e., I input lots of written prompts and equations, and I get out PNG's of each question prompt and choice A-E). Is there any good place I can start learning the necessary skills to properly use Wolfram Cloud/Language? I would happily pay for a great tutorial. I just stumbled across this stuff and feel like I could use this technology to really improve my productivity and content.

Thank you all!

POSTED BY: Uzair Qarni

Restricted depends heavily on the type (its first argument). The documentation for Restricted doesn't cover its full behavior, just a very large set of common ways that it is used.

Look at the documentation for things like "Expression" and "MathExpression" under "Restriction Specifications". These documentation pages cover how Restricted is used with them.

http://reference.wolfram.com/language/ref/interpreter/Expression.html

The documentation pages for Interpreter types also have examples of how Restricted is used with them.

POSTED BY: Sean Clarke

Hello Sean,
A few hours ago i tried to solve this question but failed because I could not get the context of the to be plotted function and its variable in the same shape.

I studied the definition of Restricted and searched for the reasons why you set arg 2 to auto, arg 3 to auto and arg 4 to "LocalContext`".
I am unable to find the meaning behind the arguments 2,3 and 4 in the documentation. Could you please elaborate a bit on why you used this form and where to find it in the documentation.

The issue is somewhat complicated.

If Plot is given something that isn't the correct form, it makes a blank plot.

The rest is somewhat difficult to explain without more experience. Your code above doesn't put variables into a proper context. Contexts are much like namespaces in other languages. In the example below, I have "MathExpresion" put all the variables into a context called "LocalContext" and then use that context in your code:

CloudDeploy[
 FormFunction[{"equation" -> Restricted["MathExpression", Automatic, Automatic, "LocalContent`"]}, 
             Plot[#equation, {LocalContent`x, -10, 10}] &, 
             "PNG"]
]

The & operator defines something called a pure or anonymous function.

Is there somewhere you copied this code from? I'd like to check that it explains some of this if possible.

POSTED BY: Sean Clarke
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