fancylojban challenges: Difference between revisions
Spheniscine (talk | contribs) |
Spheniscine (talk | contribs) No edit summary |
||
Line 12: | Line 12: | ||
[[zipcpi:_solution-fermat-1|Solution]] by [[User:Spheniscine|la zipcpi]] (now solves subproblem #1, by refactoring to use {PA broda -> PA da poi broda}) | [[zipcpi:_solution-fermat-1|Solution]] by [[User:Spheniscine|la zipcpi]] (now solves subproblem #1, by refactoring to use {PA broda -> PA da poi broda}) | ||
== Quadratic Equation (ma'ormekso or brimekso? You decide!) == | |||
If https://upload.wikimedia.org/math/0/c/4/0c4913db725b72609d4825124dda12aa.png, then https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Quadratic_formula.svg/220px-Quadratic_formula.svg.png | |||
== Euclid's Algorithm for Greatest Common Divisor == | == Euclid's Algorithm for Greatest Common Divisor == |
Revision as of 14:32, 1 August 2015
Lojban is supposed to be a logical language, so why not practice translating some common mathematical statements, or algorithms
Additional challenge: Don't use mekso with VUhU. Or use them, if you prefer the challenge of wrangling with mekso grammar...
Fermat's Last Theorem
(The statement, not the proof, of course!)
"No three positive integers a, b, and c can satisfy the equation an + bn = cn for any integer value of n greater than two."
Subproblem #1: How to explicitly make letter pronouns or ko'a-series existential, without having to assign {daxivo goi ny} e.g.?
Solution by la zipcpi (now solves subproblem #1, by refactoring to use {PA broda -> PA da poi broda})
Quadratic Equation (ma'ormekso or brimekso? You decide!)
If , then
Euclid's Algorithm for Greatest Common Divisor
function gcd(a, b) if b = 0 return a else return gcd(b, a mod b)
Also try a non-recursive version, but we'd probably need a new brivla for while-loop, and {tu'e...tu'u} in NU.
Subproblem #1: come up with a better brivla to define than one based on the abbreviation "gcd"
Recursive solution by la zipcpi (doesn't solve subproblem #1)
Non-recursive solution by la zipcpi (uses {ganfauke} for while-loop, {goilka'i} and {goilbi'o} as suggested below, and {tu'e...tu'u} in NU)
Towers of Hanoi
x1 is the sequence of moves that move discs from x2 to x3 using x4 as temporary storage.
Recursive solution by la xalbo
While-loop brivla - English and Lojban definitions
In the vein of ifle, we might need brivla suitable for describing while-loops...
While-loop: (now defined as ganfauke)
As long as x1 (du'u proposition) is true, x2 (action/event) repeatedly happens
Do-while-loop: (now defined as faubganke)
x1 (action/event) happens, then repeats as long as x2 (du'u proposition) is true.
With ko'oi / gau ko / ko gasnu lo nu turning it into a command that the agent (whether it's a computer or a person) should follow.
Question: Can Lojban, as designed, actually handle this? Can KOhA and letteral variables be reinterpreted in an existing du'u-proposition, or does the proposition remain the same even if the variables get goi-ed to something else?
Thoughts: Perhaps, don't use {goi}. {goi} is problematic for any use other than assigning nonce pronouns anyway, due to ambiguity of directionality. Instead, for something like "var x = 1; x = x + 1", we use brivla that says that x is a variable *standing in* for some object (e.g. something like {ko'oi la .xys. cu goilka'i li pa .i ko'oi la .xys. cu goilka'i le sumji be [la'e?] la .xys. bei li pa}) . This allows the variables to change without actually changing the objects themselves, and allows the truth value of that du'u-proposition to change.
goilka'i tentative definition
goilka'i: x1 (quoted-pronoun or object) is a variable representing x2 (any sumti).
{goi} is a special case where {zo ko'a} (e.g.) becomes a goilka'i of something. However the main use of goilka'i is to allow {ko'a} itself, or {la .xys.}, not {zo ko'a}, to be variables. In effect, a goilka'i is a virtual textual object, and {la'e} is used to extract the referent from the "text".
goilbi'o: x1 (goilka'i variable) changes value to now represent x2
Informal algorithms
Instructional texts like cookbooks or game rules, that might have use for certain programming-language-like structures, but which might not need to be specified to the last detail like programming languages...