Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/dok.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkoray kavukcuoglu <koray@kavukcuoglu.org>2012-08-09 02:21:51 +0400
committerkoray kavukcuoglu <koray@kavukcuoglu.org>2012-08-09 02:21:51 +0400
commitc004da2f3712e02f27ac0b687c1b78f03e480fcf (patch)
treeeb0bc57f20811fb83dd71f47471f80464aa37cab
parent905a181a859a88b847391af35b577994a8e737aa (diff)
Update pkg/dok/doktutorial/index.dok
buggy function tutorial
-rw-r--r--doktutorial/index.dok13
1 files changed, 7 insertions, 6 deletions
diff --git a/doktutorial/index.dok b/doktutorial/index.dok
index c41dcae..eefc3c3 100644
--- a/doktutorial/index.dok
+++ b/doktutorial/index.dok
@@ -187,7 +187,8 @@ t7>
Easy right?
-So we've seen a couple of basic types already: strings, numbers, tables, booleans (true/false). There's one last type in Lua: the function. Functions are first-order citizens in Lua, which means that they can be treated as regular variables. This is great, because it's the reason why we can construct very powerful data structures (such as objects) with tables:
+So we've seen a couple of basic types already: strings, numbers, tables, booleans (true/false). There's one last type in Lua: the function.
+are first-order citizens in Lua, which means that they can be treated as regular variables. This is great, because it's the reason why we can construct very powerful data structures (such as objects) with tables:
<file lua>
t7> h = {firstname='Paul', lastname='Eluard', age='117',
@@ -233,11 +234,11 @@ A few more things about functions: functions in Lua are proper closures, so in c
<file lua>
myfuncs = {}
for i = 1,4 do
- local calls = 10
- myfuncs[i] = function()
- calls = calls + 1
- print('this function has been called ' .. i .. 'times')
- end
+ local calls = 0
+ myfuncs[i] = function()
+ calls = calls + 1
+ print('this function has been called ' .. calls .. ' times')
+ end
end
t7> myfuncs[1]()