Message Boards Message Boards

0
|
3291 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Can I use my own function

Posted 9 years ago

When deploying a function in the Cloud, can I use functions that I have defined myself. Like in this example:

form=FormFunction[{"x"->"Number","y"->"Number"}, (AddTwoNumbers AddTwoNumbers[#])&]

CloudDeploy[form]

The immediatet answer based on experience is that I cannot - but why, and what to do instead?

POSTED BY: Per Hedegard

Yes, you can. There's a couple of things wrong here though.

You can't define a function like this:

AddTwoNumbers[<|"x"->x,"y"->y|>]:=x+y;

Associations are atomic, so don't use them in pattern matching.

The values of x and y will be represented by #x and #y. Here is the code I would use:

addTwoNumbers[x_, y_] := x + y
form = FormFunction[{"x" -> "Number", "y" -> "Number"}, addTwoNumbers[#x, #y] &]
CloudDeploy[form, Permissions -> "Public"]
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