Mathematica 7 compares to other languages

Dotan Cohen dotancohen at gmail.com
Wed Dec 10 22:13:05 CET 2008


2008/12/10  <w_a_x_man at yahoo.com>:
> On Dec 5, 9:51 am, Xah Lee <xah... at gmail.com> wrote:
>>
>> For those of you who don't know linear algebra but knows coding, this
>> means, we want a function whose input is a list of 3 elements say
>> {x,y,z}, and output is also a list of 3 elements, say {a,b,c}, with
>> the condition that
>>
>> a = x/Sqrt[x^2+y^2+z^2]
>> b = y/Sqrt[x^2+y^2+z^2]
>> c = z/Sqrt[x^2+y^2+z^2]
>
>>
>> In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
>> you'll have 50 or hundreds lines.
>
> Ruby:
>
> def norm a
>  s = Math.sqrt(a.map{|x|x*x}.inject{|x,y|x+y})
>  a.map{|x| x/s}
> end

If someone doesn't counter with a Python one-liner then I'm going to
port that to brainfuck.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü


More information about the Python-list mailing list