-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanual_test.lua
More file actions
53 lines (38 loc) · 1.19 KB
/
manual_test.lua
File metadata and controls
53 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package.path = package.path .. ";./lua/?.lua"
package.path = package.path .. ";./lua/?/init.lua"
vim = {}
local tools = require("tools")
local map = tools.map
local foreach = tools.foreach
local curry = tools.curry
local unpack = table.unpack or unpack
local tolist = tools.tolist
local animals = map({dog="perro", cat="gato", parrot="loro"}, function(animal, key)
print(animal)
return animal .. " oh!" .. key
end)
foreach(animals, print)
print "----------------"
animals = map({"perro", "gato", "loro"}, function(animal, key)
print(animal)
return animal .. " oh!" .. key
end)
print "\nContiene el indice"
foreach(animals, print)
print "\nSuprime el indice"
foreach(animals, function (animal) print(animal) end)
local function hi(a,b,c)
print(a,b,c)
end
print({"hi", "sopa", "mundo"})
print(unpack{"hi", "sopa", "mundo"})
print "------------- LIST"
foreach(tolist({va=2,yp=3,4,5}), print)
print "---- Curry ----"
local sayHello = curry(function(name, from, postfix)
print("Hola "..name.." desde "..from.." :) "..(postfix or ":c"))
end)
local toPedro = sayHello("Pedro")
toPedro("Guatemala", "Usa 2 argumentos")
local toPedroFromGuate = toPedro("Guatemala")
toPedroFromGuate("Secuencial")