Calling out to WolframAlpha™

Discuss your code, get questions answered

Calling out to WolframAlpha™

Postby oliver » Sat Mar 12, 2011 8:21 am

For programmers, here's how the info command of the ChemFormula type (from the Chem shared folder) is implemented:
Code: Select all
   "info": function(a) { calculator.functions.callWA("", a.stringValue); },


You can use the same technique for your own types. Or, indeed, within any regular JavaScript function.

Specify a WolframAlpha command instead of "", where required.
For example, to differentiate an expression, you'd say "derivative", to obtain a Taylor expansion, you'd say "taylor", and so on.
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Re: Calling out to WolframAlpha™

Postby oliver » Mon Apr 16, 2012 6:44 am

Note: the technique here doesn't require the new CAS option and license.

Even though the functions are named the same, they're very different: ME.callWA(), the function described here, is a user function which forms a Wolfram|Alpha™ URL and opens wolframalpha.com in ND1's browser. (The ND1 display is a HTML5 document at all times, actually.)
That is, it provides a courtesy mechanism to get you to the W|A website.

The function calculator.callWA(), discussed in "Extending the CAS", is a function that's currently only accessible to JavaScript programmers, which performs a W|A commercial API query and returns the result on the stack. It tightly integrates ND1 with W|A and Mathematica™ and requires a user CAS license, which will be available as an in-app purchase in ND1 v1.5 and up.
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron