What I Learned Today      [ New Post ]

Tuesday, July 19, 2005

Old PHP gem

I wrote this nugget of code back in Feb 2002. It got some really good reviews on the various PHP sites. :)
To find the position of the start of the last occurence of a string, we can do this:
$pos=strlen($haystack) -
(strpos(strrev($haystack), strrev($needle)) + strlen($needle));

The idea is to reverse both $needle and $haystack, use strpos to find the first occurence of $needle in $haystack, then count backwards by the length of $needle. Finally, subtract $pos from length of $haystack. A lot easier to figure out if you use a test string to visualize it. :)

Friday, July 15, 2005

Naruwan Hawaiki

It's been pretty well established through liguistics and cultural anthropology that modern Polynesians, including Hawai'ians, are related to the various aboriginal tribes of Formosa. But until recently, genetic evidence had yet to be gathered. Jean Trejaut and Marie Lin, of Mackay Memorial Hospital in Taipei, have taken on the task, and report their findings in Public Library of Science Biology. From the synopsis:

Taken together, these results suggest that Taiwanese aboriginal populations have genetically been isolated from mainland Chinese for 10,000 to 20,000 years, though the whereabouts of their origin in the Asian region is still unclear. Additionally, these results demonstrate that Polynesian migration most likely originated from people identical to the aboriginal Taiwanese. These findings provide the first direct evidence for the common ancestry of Polynesians and indigenous Taiwanese, and suggest that Taiwan genetically belongs to that region of insular Southeast Asia that might have been the point from where Polynesians started their migration across the Pacific, followed by later cultures that developed from their descendents in east Indonesia and Melanesia. Further research will be necessary to accurately determine the origins of the aboriginal Taiwanese; however, these results are a step towards clarifying the origins of Polynesians.

That's a lot less unwieldly than the highly technical language of the report's authors in its conclusion:

Taiwanese aboriginal populations share their maternal ancestry with populations of mainland East Asia through haplogroups B, R9, and M7 as their main genetic components. At the same time the haplogroup structure at a finer phylogenetic resolution suggests relatively long-term isolation from the mainland populations. The coalescence times of B4a1a, F3b, F4b, R9c, and M7c1c lineages point to founder effects in Taiwan ranging from recent (0–2,000 years) to more ancient times (7,000–20,000 years). These results most likely reflect the drift in small endogamous populations of the island that became isolated by the rising sea levels after the last Ice Age.

The time element (13.2 ± 3.8 thousand years to the MRCA) obtained from the phylogenetic reconstruction of complete B4a1a sequences requires that we adopt a model according to which the origin of Austronesian migration can be traced back to Taiwan, and allows for the notion that it was followed by interaction periods elsewhere in Indonesia and finally in Melanesia where the complete motif specific to Polynesian B4a1a1 sequences (Polynesian motif) was developed.

As The Economist puts it:

In a study involving 640 people from nine Taiwanese tribes, Dr Trejaut and Dr Lin found three mutations shared by Taiwanese, Polynesians and Melanesians (who also speak Austronesian) which are not found in other Asians. So the mystery seems to have been solved at last. Where the Taiwanese came from, though, is a different question again.

So there you have it. Taiwan is Hawaiki, the homeland of Maori legend.

[Cross-posted at Between Worlds and Naruwan Formosa]