samtrosku examples: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
=='''nu'a ne'o''' (factorial)== | =='''nu'a ne'o''' (factorial)== | ||
Assuming that factorial isn't a built-in operation with {{jvs|ne'o | Assuming that factorial isn't a built-in operation with {{jvs|ne'o}}, you could implement it as the brivla {{vlapoi|nu'a|ne'o}}: | ||
<tab class=wikitable> | <tab class=wikitable> | ||
.i ca'e ko'a nu'a ne'o ko'e ijo ('X == Y factorial' is defined as:) | .i ca'e ko'a nu'a ne'o ko'e ijo ('X == Y factorial' is defined as:) |
Latest revision as of 06:36, 14 April 2015
coi (Hello)
(the quintessential first program)
Program:
.i ko cusku lo'u ui coi munje le'u
Output:
.ui coi munje
(Yes, a dot would be inserted - I assume that in displaying Lojban strings, which are different from character strings, the samtrosku interpreter would choose the most canonical form).
nu'a ne'o (factorial)
Assuming that factorial isn't a built-in operation with ne'o, you could implement it as the brivla nu'a ne'o: <tab class=wikitable> .i ca'e ko'a nu'a ne'o ko'e ijo ('X == Y factorial' is defined as:) tu'e ny goi 1 (n = 1) .i ko zukte di'e ca le du'u ko'e zmadu li 1 (while Y > 1 do this...) .itu'e ko dungau ny li ny pi'i ko'e (n = n*Y) .i ko dungau ko'e li ko'e vu'u 1 (Y = Y-1) tu'u .i ko'a jagdu'o ny (return n as the value of X) tu'u </tab>