samtrosku examples

coi (the quintessential first program)

.i ko cusku lo'u ui coi munje le'u

.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}:

.i ca'e ko'a nu'a ne'o ko'e ijo ('X == Y factorial' is defined as:)
ny goi 1 (n = 1)
.i ko zukte di'e ca le du'u ko'e zmadu li 1 (while Y > 1 do this...)
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)
.i ko'a jagdu'o ny (return n as the value of X)

Created by admin. Last Modification: Friday 30 of November, 2001 12:31:04 GMT by admin.