Mathematica 7 compares to other languages

Xah Lee xahlee at gmail.com
Thu Dec 11 19:36:42 CET 2008


Xah Lee wrote:

• A Example of Mathematica's Expressiveness
  http://xahlee.org/UnixResource_dir/writ/Mathematica_expressiveness.html

On Dec 11, 3:53 am, "William James" <w_a_x_... at yahoo.com> wrote:
> function normal( ary )
> { var div = Math.sqrt(
>     ary.map(function(x) x*x).reduce(function(a,b) a+b) )
>   return ary.map(function(x) x/div)
>
> }

I run your code in SpiderMonkey:

// SpiderMonkey javascript. By William James.
function normal(v) {
var div=Math.sqrt(v.map(function(x) x*x).reduce(function(a,b) a+b))
  return v.map(function(x) x/div)
}

print normal [3,4];

i got:

/Users/xah/Documents/temp/xx.js:3: SyntaxError: missing { before
function body:
/Users/xah/Documents/temp/xx.js:3: var div=Math.sqrt(v.map(function(x)
x*x).reduce(function(a,b) a+b))
/Users/xah/Documents/temp/xx.js:
3: ....................................^

  Xah
∑ http://xahlee.org/


More information about the Python-list mailing list