From: Dr J R Stockton on
In comp.lang.javascript message <7fe7b790-e599-4592-a83d-8526174bacfe(a)y3
0g2000yqh.googlegroups.com>, Mon, 26 Apr 2010 04:28:58, Sean Kinsey
<okinsey(a)gmail.com> posted:
>On Apr 26, 4:09�am, Stefan Weiss <krewech...(a)gmail.com> wrote:
><snip>
>> I swear, one of these days I'm going to learn Russian. There's a huge
>> part of the web that I don't have access to, and that bugs me.
>
>Haven't you tried Google Chrome with its translation feature?

There is no *need* to use Chrome for that; one can go to
<http://translate.google.com/?langpair=it|en#> directly, and remove or
adjust the language pair. I don't know what the hash is for.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 7.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
MiniTrue is good for viewing/searching/altering files, at a DOS / CMD prompt;
free, DOS/Win/UNIX, new via <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.
From: Michael Wojcik on
Dr J R Stockton wrote:
> In comp.lang.javascript message <7fe7b790-e599-4592-a83d-8526174bacfe(a)y3
> 0g2000yqh.googlegroups.com>, Mon, 26 Apr 2010 04:28:58, Sean Kinsey
> <okinsey(a)gmail.com> posted:
>> On Apr 26, 4:09 am, Stefan Weiss <krewech...(a)gmail.com> wrote:
>> <snip>
>>> I swear, one of these days I'm going to learn Russian. There's a huge
>>> part of the web that I don't have access to, and that bugs me.
>> Haven't you tried Google Chrome with its translation feature?
>
> There is no *need* to use Chrome for that; one can go to
> <http://translate.google.com/?langpair=it|en#> directly, and remove or
> adjust the language pair. I don't know what the hash is for.

The hash is the delimiter for an empty fragment identifier. An empty
fragment ID is a no-op for an HTTP URL, but it appears that Google
Translate's URL canonicalization will add it if you omit it.

You can also add "&text=[URL-encoded text in source language]" to the
URL, and have the page appear with the translation:

http://translate.google.com/?langpair=it|en&text=ciao#

in which case, at least if you have a small viewport, the "#autotrans"
fragment identifier might be useful:

http://translate.google.com/?langpair=it|en&text=ciao#autotrans

--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University
From: Spamless on
On 2010-04-26, VK <schools_ring(a)yahoo.com> wrote:
> While trying to port the promised Shannon's Clairvoyant code to
> Javascript, I am having real troubles to figure out what that would be
> in Javascript: 5-dimensional array ...

I wouldn't. Suppose you want to have five dimension, let me index them
from 0 through 4 and want to hold data with index (a,b,c,d,e) where the
first index has A possible values (from 0 throut A-1), the second has
B values (from 0 through B-1), etc. I would construct a one dimensional
array of size A*B*C*D*E, say MYARRAY and use the function:
_indexer(a,b,c,d,e) = {return ((((e*D+d)*C+c)*B+b)*A+a)}
as MYARRAY[_indexer(a,b,c,d,e)]

It is easy enough to calculate _indexer. It gives a single number from
five and that number is unique (once you know it, take the result mod(A)
to find a mod A, but as a can only vary from 0 through A-1, you know A.
Subtract to get (((e*D+d)*C+c)*B+b)*A, divide by A to get ((e*D+d)*C+c)*B+b
and take that mod B to get b mod B. But b can only vary from 0 through B-1
so you know b ... in short, once you have that single number it gives the
five numbers which are used to create it).

This one-one mapping maps to the range 0 through A*B*C*D*E-1, A*B*C*D*E
consecutive integers to hold just that many elements (which would be
required by the five dimensional array).

There *are* ways to do it if you don't know A,B,C,D,E, but they can
be inefficient (find some one-one mappying from five non-negative
integers into the integers) in that it may not map to all consecutive
integers in the smallest range.
From: VK on
On May 1, 6:06 am, Spamless <Spaml...(a)Nil.nil> wrote:
> On 2010-04-26, VK <schools_r...(a)yahoo.com> wrote:
>
> > While trying to port the promised Shannon's Clairvoyant code to
> > Javascript, I am having real troubles to figure out what that would be
> > in Javascript: 5-dimensional array ...
>
> I wouldn't. Suppose you want to have five dimension, let me index them
> from 0 through 4 and want to hold data with index (a,b,c,d,e) where the
> first index has A possible values (from 0 throut A-1), the second has
> B values (from 0 through B-1), etc. I would construct a one dimensional
> array of size A*B*C*D*E, say MYARRAY and use the function:
> _indexer(a,b,c,d,e) = {return ((((e*D+d)*C+c)*B+b)*A+a)}
> as MYARRAY[_indexer(a,b,c,d,e)]
>
> It is easy enough to calculate _indexer. It gives a single number from
> five and that number is unique (once you know it, take the result mod(A)
> to find a mod A, but as a can only vary from 0 through A-1, you know A.
> Subtract to get (((e*D+d)*C+c)*B+b)*A, divide by A to get ((e*D+d)*C+c)*B+b
> and take that mod B to get b mod B. But b can only vary from 0 through B-1
> so you know b ... in short, once you have that single number it gives the
> five numbers which are used to create it).
>
> This one-one mapping maps to the range 0 through A*B*C*D*E-1, A*B*C*D*E
> consecutive integers to hold just that many elements (which would be
> required by the five dimensional array).

You just answered it before I got ready to post myself :-( :-)
Indeed I was getting nuts by trying to visualize that "5-dimensional
array of 72 elements" because I hate to use things I do not "see" even
if they work properly. Finally I realized that numOfNodes-dimensional
real array just unnecessarily obfuscates the otherwise simple picture.
In fact we have a symmetrical binary tree with 5 node steps and 64
leaves. On each of five steps we have to either turn left or turn
right. Let's denote left turn as zero and right turn as 1. This way
the path to each leaf is one of permutations between 00000 (all left
turns) and 11111 (all right turns). Let's look at these permutations
as binary numbers. Let's also introduce the "holding bit" on the left
to prevent zeros collapsing if we ever need to stringify the path. The
set of paths to each leaf is then the set of binary numbers 100000 -
111111 (decimal 32 - 63).
The universal init algorithm then is as simple as:

function initTree(numOfNodes) {
var Tree = new Array();
// var Tree = new Object();
var lBound = '';
var uBound = '';

do {
lBound+= '0';
} while (lBound.length < numOfNodes);
lBound = parseInt('1'+lBound, 2);

do {
uBound+= '1';
} while (uBound.length < numOfNodes);
uBound = parseInt('1'+uBound, 2);

for (var i = lBound; i<uBound; i++) {
Tree[i] = 0; // or another init value
}
return Tree;
}

The algorithm can be further improved of course. For instance it is
highly tempting to use binary logical operators AND, OR, XOR instead
of string manipulations in order to get paths and later to match the
given path to the leaf value. It is tempting as it would be first ever
practical and logical use of binary logical operators in JavaScript I
would ever saw.

The beauty of this approach is that it works for ternary and higher
orders trees as well. One just need to think for say ternary tree
(left, straight, right choice on each node) as a set of two wrong
choices and one right choice. By denoting wrong with 0 and right with
1 we are getting 001, 010, 100 and respectively the full set of paths
will be found in a range of base-3 numbers with the right choice for
each node being a trit in that number. So on for base-4, base-5 etc.

I am sure that all that is already written in tree books but I arrived
to that completely by my own so cannot resist to state how proud I am
of myself :-)

P.S. I am wondering if it would be more effective or equal for storing
paths: to use properties of Object instance or to use sparse Array
instance?
From: VK on
On May 1, 8:13 am, VK <schools_r...(a)yahoo.com> wrote:
> The beauty of this approach is that it works for ternary and higher
> orders trees as well. One just need to think for say ternary tree
> (left, straight, right choice on each node) as a set of two wrong
> choices and one right choice. By denoting wrong with 0 and right with
> 1 we are getting 001, 010, 100 and respectively the full set of paths
> will be found in a range of base-3 numbers with the right choice for
> each node being a trit in that number.

The latter means that it is possible to build an analog of neural
quantum network and entanglement states using tools of JavaScript.
Just each trit has to be a qubit like

function Qubit(entangledQubit) {
this.superposition = true;
this.entangledQubit = entangledQubit || null;
this.state = -1;
this.mesure = Qubit.mesure;
}
Quibit.mesure = function() {
this.superposition = false;
var n = Math.floor(Math.random()*2);
this.state = (n==2) ? 1 : 0;
this.entangledQubit.state = !this.state;
}

It's all highly sketchy and not even sure if practically applicable
but hell, I have to think of it immediately...

-