![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
Becka had asked for a list of all syllables of her first language, and I made a little script using javascript (because you only need a browser to "run" that).
You can see it here. If you'd like to adapt it for your own language, save that page to your own computer, and open it in a text editor (for example Notepad). If you want to see the results, open the file in a browser.
Becka would also like a list of all syllables from her pseudo-polynesian language according to the rule (C)V(stop or nasal)
So, let's get to changing the script.
Make a copy of the script so you can change things.
The example has only two lists of sounds, but we need three: C, V, and stop-or-nasal, let's call that S.
You can make as many lists as you need, and name them whatever you like. (The names are marked with colours here).
Then we need to split the rule that includes optionals into several that don't. The result is V (a, i, u, we can just list that by hand), CV, VS and CVS
CV is already covered in the example.
document.write("\n<h2>CV</h2>\n"); just prints "CV" formatted as a headline for the list.
for (i in consonants) { ... }
This is a loop. Everything in the brackets is executed once for each element in the list called "consonants". The i is not the letter i, but a variable that's used as a counter. If you need the number of the element that is being worked on now, it is in this variable. You can pick the names for those freely, they just need to match when you use them.
for (j in vovels) {...}
is the same, only over the "vovels" list and using a differently named counter.
So those nested loops basically say "take each consonant, for each of them take each vovel, and do document.write( consonants[i] + vovels[j] + "<br>\n");"
consonant[i] is the "i-th" consonant - with our list p on the first turn of the outer loop, t on the second, etc. - vovels[j] the "j-th" vovel - a on the first, i on the second, u on the third turn of the inner loop. The inner loop in this modified example runs 3 times during each turn of the outer loop (because there are 3 vovels in our list).
Let's adapt that for the second rule, VS. That is vovels in the outer loop, and written first, stop-or-nasal in the inner loop, and written second.
You can nest as many for loops as you want (more or less), just make sure you use a different name for the counter, and the number of opening brackets matches the number of closing brackets.
Now we remove the remaining loops from the original example, and we're done.
The pseudo-polynesian syllables
I hope that makes sense.
You can see it here. If you'd like to adapt it for your own language, save that page to your own computer, and open it in a text editor (for example Notepad). If you want to see the results, open the file in a browser.
Becka would also like a list of all syllables from her pseudo-polynesian language according to the rule (C)V(stop or nasal)
So, let's get to changing the script.
Make a copy of the script so you can change things.
The example has only two lists of sounds, but we need three: C, V, and stop-or-nasal, let's call that S.
You can make as many lists as you need, and name them whatever you like. (The names are marked with colours here).
var vovels = new Array("a", "i", "u"); var consonants = new Array("p", "t", "k", "f", "s", "h", "r", "w", "l", "m", "n"); var sn = new Array("p", "t", "k", "m", "n");
Then we need to split the rule that includes optionals into several that don't. The result is V (a, i, u, we can just list that by hand), CV, VS and CVS
CV is already covered in the example.
document.write("\n<h2>CV</h2>\n"); for (i in consonants) { for (j in vovels) { document.write( consonants[i] + vovels[j] + "<br>\n"); } }
document.write("\n<h2>CV</h2>\n"); just prints "CV" formatted as a headline for the list.
for (i in consonants) { ... }
This is a loop. Everything in the brackets is executed once for each element in the list called "consonants". The i is not the letter i, but a variable that's used as a counter. If you need the number of the element that is being worked on now, it is in this variable. You can pick the names for those freely, they just need to match when you use them.
for (j in vovels) {...}
is the same, only over the "vovels" list and using a differently named counter.
So those nested loops basically say "take each consonant, for each of them take each vovel, and do document.write( consonants[i] + vovels[j] + "<br>\n");"
consonant[i] is the "i-th" consonant - with our list p on the first turn of the outer loop, t on the second, etc. - vovels[j] the "j-th" vovel - a on the first, i on the second, u on the third turn of the inner loop. The inner loop in this modified example runs 3 times during each turn of the outer loop (because there are 3 vovels in our list).
Let's adapt that for the second rule, VS. That is vovels in the outer loop, and written first, stop-or-nasal in the inner loop, and written second.
document.write("\n<h2>VS</h2>\n"); for (i in vovels) { for (j in sn) { document.write( vovels[i] + sn[j] + "<br>\n"); } }
You can nest as many for loops as you want (more or less), just make sure you use a different name for the counter, and the number of opening brackets matches the number of closing brackets.
document.write("\n<h2>CVS</h2>\n"); for (i in vovels) { for (j in consonants) { for (k in sn) { document.write( vovels[i] + consonants[j] + sn[k] + "<br>\n"); } } }
Now we remove the remaining loops from the original example, and we're done.
The pseudo-polynesian syllables
I hope that makes sense.
no subject
Date: 2011-11-25 04:09 pm (UTC)I'm pretty sure this is awesome.
no subject
Date: 2011-12-06 03:07 am (UTC)Shall try again in the morning when awake.
no subject
Date: 2011-12-06 02:35 pm (UTC)no subject
Date: 2011-12-06 02:36 pm (UTC)no subject
Date: 2011-11-26 12:33 am (UTC)And the syllable set for the Island People seems nicely managable.