Message Boards Message Boards

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

Why does the "APIFunction" require the successive code on the same line?

Posted 10 years ago
POSTED BY: Matt Brauer
6 Replies
Posted 10 years ago

Arnoud,

That is precisely the error I am experiencing.

David,

I'm glad that you too were able to verify the issue.

POSTED BY: Matt Brauer

Matt,

This is the error you are seeing?

enter image description here

(I think it is, but just wanted to make sure before continuing).

POSTED BY: Arnoud Buzing

If I paste the code into a Programming Cloud notebook (it includes the carriage return after the first line as you posted it) it works fine. Then I delete the carriage return and add it back in and execute the code again and get your error message. So something is indeed amiss on the Cloud...

POSTED BY: David Reiss
Posted 10 years ago

I am using it on the Wolfram Programming Cloud. Its interesting that it works on your local copy of Mathematica.

I also tried copying the code into a fresh notebook and the same issue occurred. Just in case, I also tried retyping it explicitly instead of copying it and that didn't help either.

The two pieces common to the problem seem to be the APIFunction and using it in the Wolfram Programming Cloud.

Thanks for looking into it. If you have any more suggestions I am open to them!

I also tried this simpler code with the APIFunction and had the same issues:

INPUT:

addf[x_,y_]:=
x+y; 
test = APIFunction[{"g" -> "Integer", "Hf"->"ZIPCode"}, addf[#g,#Hf] &];
test[<|"g"->5, "Hf"->"ZIP 47025"|>]

OUTPUT:

<|g->5 g+5 Hf,Hf->6 g+6 Hf|>

Again, if I combine the "addf" function, APIFunction, and the inputs on the same line, the output works fine.

POSTED BY: Matt Brauer

That's strange. The code seems to run fine for me too. Maybe there was some sort of stray character that was added. Try copying your code from this webpage into a fresh notebook and then running it. Do you still see the problem?

POSTED BY: Sean Clarke

It appears to work fine on my system (OSX Yosemite with Mathematica 10.01)

POSTED BY: David Reiss
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