Utilisateur:Gerardgiraud/brouillon/Chiffre

Une page de Wikiversité, la communauté pédagogique libre.

<syntaxhighlight lang="lua">

local p = {}

function p.traduit(frame) --Fonction traduisant un chiffre en toutes lettres local reponse = "Chiffre non reconnu" local chiffre = frame.args[1] --La variable chiffre recueille le premier argument entré sous forme de nombre if chiffre == 0 then reponse = "zéro" end if chiffre == 1 then reponse = "un" end if chiffre == 2 then reponse = "deux" end if chiffre == 3 then reponse = "trois" end if chiffre == 4 then reponse = "quatre" end if chiffre == 5 then reponse = "cinq" end if chiffre == 6 then reponse = "six" end if chiffre == 7 then reponse = "sept" end if chiffre == 8 then reponse = "huit" end if chiffre == 9 then reponse = "neuf" end return reponse end

return p