Difference between revisions of "Template:Lua programming language"

From blackwiki
Jump to navigation Jump to search
imported>Aither~enwiki
(Undid revision 428871010 by 99.184.73.79 (talk))
Line 1: Line 1:
print("Hello World!")
+
{{Navbox
function factorial(n)
+
|name  = Lua programming language
  if n == 0 then
+
|title = [[Lua (programming language)|Lua programming language]]
    return 1
+
 
  else
+
|group1= Interpreters and compilers <!-- implementations, not ports -->
    return n * factorial(n - 1)
+
|list1 = [[Lua (programming language)|Lua]]{{·}} [[Parrot virtual machine|Parrot]]
  end
+
 
end
+
|group2= Frameworks and libraries
function factorial2(n)
+
|list2 = [[IUP (software)|IUP]]{{·}} [[Kepler (software)|Kepler]]{{·}} [[LÖVE]]
  return n == 0 and 1 or n * factorial2(n - 1)
+
 
end
+
|group3= Ports and distributions
do
+
|list3 = [[Plua]]{{·}} [[Lua Player]]{{·}} [[Corona (software development kit)|Corona]]
  local oldprint = print  -- Store current print function as oldprint
+
 
  function print(s)        -- Redefine print function
+
|group4= IDE
    if s == "foo" then
+
|list4 = [[Unknown Worlds Entertainment|Decoda]]{{·}} [[SciTE]]{{·}} [[Comparison of integrated development environments#Lua|comparison]]
      oldprint("bar")
+
 
    else
+
|group5= Applications
      oldprint(s)
+
|list5 = [[Prosody (software)|Prosody]]
    end
+
  end
+
}}<noinclude>
end
+
[[Category:Programming language templates|Lua]]
function addto(x)
+
[[Category:Lua programming language|τ]]
  -- Return a new function that adds x to the argument
+
[[ru:Шаблон:Lua]]
  return function(y)
+
</noinclude>
    -- When we refer to the variable x, which is outside of the current
 
    -- scope and whose lifetime is longer than that of this anonymous
 
    -- function, Lua creates a closure.
 
    return x + y
 
  end
 
end
 
fourplus = addto(4)
 
print(fourplus(3))  -- Prints 7
 
fibs = { 1, 1 }                         -- Initial values for fibs[1] and fibs[2].
 
setmetatable(fibs, {                    -- Give fibs some magic behavior.
 
  __index = function(name, n)           -- Call this function if fibs[n] does not exist.
 
    name[n] = name[n - 1] + name[n - 2] -- Calculate and memorize fibs[n].
 
    return name[n]
 
  end
 
})
 

Revision as of 17:45, 13 May 2011

ru:Шаблон:Lua