Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio
- > 1+1
- stdin:1: unexpected symbol near '1'
- > =1+1
- 2
- > jmeno=muficek
- > =jmeno
- nil
- > =fhgrgfhg
- nil
- > jmeno="muficek"
- > return jmeno
- muficek
- > =jmeno>"ahoj"
- true
- > =28<35
- true
- > =34<23
- false
- > =jmeno == "muficek"
- true
- > return jmeno == "mufic"
- false
- > return jmeno ~= "mufic"
- true
- > nasobim3=function(n) return(n*3) end
- > nasobim3 (3)
- > =nasobim3 (3)
- 9
- > print (nasobim3(5))
- 15
- > print (nasobim3)
- function: 0x852e698
- > print (nasobim3(jmeno))
- stdin:1: attempt to perform arithmetic on local 'n' (a string value)
- stack traceback:
- stdin:1: in function 'nasobim3'
- stdin:1: in main chunk
- [C]: in ?
- > print(function(n) return(n*3) end)
- function: 0x852d2c0
- > print(function(n) return(n*3) end (5))
- stdin:1: ')' expected near '('
- > print((function(n) return(n*3) end) (5))
- 15
- > print (nasobim3(9))
- 27
- > print (n)
- nil
- > n="prdel"
- > print (n)
- prdel
- > print (nasobim3(9))
- 27
- > print (n)
- prdel
- > plnolety=function(vek) return(vek<18)
- >>
- >> )
- stdin:3: 'end' expected (to close 'function' at line 1) near ')'
- > print (not true)
- false
- > print not false
- stdin:1: '=' expected near 'not'
- > print (not false)
- true
- > print (not 2>1)
- stdin:1: attempt to compare number with boolean
- stack traceback:
- stdin:1: in main chunk
- [C]: in ?
- > print (not (2>1))
- false
- > print (not (2>1))
- false
- > plnolety=function(vek) return(vek>=18) end
- > print (plnolety(23))
- true
- > print (plnolety(17.9999)
- >> )
- false
- > for(i=17,19,0.2
- stdin:1: <name> expected near '('
- > for(i=17,19,0.2)
- stdin:1: <name> expected near '('
- > for (i in 17,19,0.2)
- stdin:1: <name> expected near '('
- > for i in 17,19,0.2 do
- >> print(i,plnolety(i))
- >> end
- stdin:1: attempt to call a number value
- stack traceback:
- stdin:1: in main chunk
- [C]: in ?
- > for (i = 17,19,0.2)
- stdin:1: <name> expected near '('
- > for i=17,19,0.2
- >> for i = 17,19,0.2 do
- print(i,plnolety(i))
- end
- stdin:2: 'do' expected near 'for'
- > for i=17,19,0.2
- for i in 17,19,0.2 do
- print(i,plnolety(i))
- end
- stdin:2: 'do' expected near 'for'
- > for i=17,19,0.2 do print(i,plnolety(i)) end
- 17 false
- 17.2 false
- 17.4 false
- 17.6 false
- 17.8 false
- 18 false
- 18.2 true
- 18.4 true
- 18.6 true
- 18.8 true
- 19 true
- > for i=17,19,1 do print(i,plnolety(i)) end
- 17 false
- 18 true
- 19 true
- > for i=17,19,0.1 do print(i,plnolety(i)) end
- 17 false
- 17.1 false
- 17.2 false
- 17.3 false
- 17.4 false
- 17.5 false
- 17.6 false
- 17.7 false
- 17.8 false
- 17.9 false
- 18 true
- 18.1 true
- 18.2 true
- 18.3 true
- 18.4 true
- 18.5 true
- 18.6 true
- 18.7 true
- 18.8 true
- 18.9 true
- > twilight=function(vek) return((vek>=8) and (vek<=15)) end
- > print (twilight(13))
- true
- > for i=7,17,0.5 do print(i,twilight(i)) end
- 7 false
- 7.5 false
- 8 true
- 8.5 true
- 9 true
- 9.5 true
- 10 true
- 10.5 true
- 11 true
- 11.5 true
- 12 true
- 12.5 true
- 13 true
- 13.5 true
- 14 true
- 14.5 true
- 15 true
- 15.5 false
- 16 false
- 16.5 false
- 17 false
- > print ({})
- table: 0x852f190
- > tabulka = {100,200,300,400,500}
- > =tabulka
- table: 0x852f3e0
- > dofile("zaklad.lua")
- {
- [1] = 1
- [2] = 2
- [3] = 3
- [4] = 4
- [5] = 5
- [6] =
- {
- [1] = "a"
- [2] = "b"
- }
- [7] = 7
- [8] = 8
- fn = function: 0x852dc48
- mrd = "prd"
- pravda = true
- }
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- >
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [5] = 500
- }
- > tabulka [5]="petset"
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [5] = "petset"
- }
- > tabulka [5]=nil
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- }
- > tabulka [99]="hovinko"
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [99] = "hovinko"
- }
- > print (tabulka[4]-tabulka[1])
- 300
- > tabulka ["hovno"]=true
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [99] = "hovinko"
- hovno = true
- }
- > tabulka [5]={}
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [5] =
- {
- }
- [99] = "hovinko"
- hovno = true
- }
- > tabulka[5] [7]="sedm"
- > tabulka[5] [8]="osm"
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [5] =
- {
- [7] = "sedm"
- [8] = "osm"
- }
- [99] = "hovinko"
- hovno = true
- }
- > tabulka[5] ["vykal"]="chcanky"
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [5] =
- {
- [7] = "sedm"
- [8] = "osm"
- vykal = "chcanky"
- }
- [99] = "hovinko"
- hovno = true
- }
- > tabulka[5].vykal="chcanky"
- > =tabulka[5].vykal
- chcanky
- > return tabulka[5].7
- stdin:1: <eof> expected near '.7'
- > tabulka.tw=twilight
- > print (tab(tabulka))
- {
- [1] = 100
- [2] = 200
- [3] = 300
- [4] = 400
- [5] =
- {
- [7] = "sedm"
- [8] = "osm"
- vykal = "chcanky"
- }
- [99] = "hovinko"
- hovno = true
- tw = function: 0x852d508
- }
- > tabulka.tw (25)
- > print tabulka.tw (25)
- stdin:1: '=' expected near 'tabulka'
- > print (tabulka.tw(25))
- false
- > print (string)
- table: 0x8519018
- > print (tab(string))
- {
- byte = function: 0x8066080
- char = function: 0x8065610
- dump = function: 0x80663e0
- find = function: 0x8066ce0
- format = function: 0x8065740
- gmatch = function: 0x8065590
- gsub = function: 0x8066cf0
- len = function: 0x8065280
- lower = function: 0x80652c0
- match = function: 0x8066cd0
- rep = function: 0x80650f0
- reverse = function: 0x8065040
- sub = function: 0x8065fa0
- upper = function: 0x8064f90
- }
- > print (tab(math))
- {
- abs = function: 0x8063ba0
- acos = function: 0x8064490
- asin = function: 0x8064450
- atan = function: 0x80643b0
- atan2 = function: 0x80643f0
- ceil = function: 0x8063b50
- cos = function: 0x8064330
- cosh = function: 0x8064370
- deg = function: 0x8063b10
- exp = function: 0x80642f0
- floor = function: 0x8063ac0
- fmod = function: 0x8064280
- frexp = function: 0x8064230
- huge = inf
- ldexp = function: 0x80641d0
- log = function: 0x80640e0
- log10 = function: 0x8064190
- max = function: 0x8063dc0
- min = function: 0x8063d50
- modf = function: 0x8064080
- pi = 3.1415926535898
- pow = function: 0x8064020
- rad = function: 0x8063a80
- random = function: 0x8063e30
- randomseed = function: 0x8063d20
- sin = function: 0x8063ca0
- sinh = function: 0x8063ce0
- sqrt = function: 0x8063c50
- tan = function: 0x8063bd0
- tanh = function: 0x8063c10
- }
- >
- >
- > =math.log (123)
- 4.8121843553724
- > print (math["log"](123))
- 4.8121843553724
- > print(print)
- function: 0x805fb60
- > print = nil
- > print (tab(string))
- stdin:1: attempt to call global 'print' (a nil value)
- stack traceback:
- stdin:1: in main chunk
- [C]: in ?
- >
- hana@hana-laptop:~/Desktop/Programovani$ lua
- Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio
- > print(print)
- function: 0x805fb60
- > tabulka={klic1=100,klic2=200}
- > print (tabulka.klic1)
- 100
- > dofile("zaklad.lua")
- {
- [1] = 1
- [2] = 2
- [3] = 3
- [4] = 4
- [5] = 5
- [6] =
- {
- [1] = "a"
- [2] = "b"
- }
- [7] = 7
- [8] = 8
- fn = function: 0x9d86c30
- mrd = "prd"
- pravda = true
- }
- > print (tab(tabulka))
- {
- klic1 = 100
- klic2 = 200
- }
- > psi={
- >> {jmeno="Albert", narozen=2002, vaha=6},
- >> {jmeno="Chucky", narozen=2003, vaha=2.5}
- >> }
- > print (tab(psi))
- {
- [1] =
- {
- jmeno = "Albert"
- narozen = 2002
- vaha = 6
- }
- [2] =
- {
- jmeno = "Chucky"
- narozen = 2003
- vaha = 2.5
- }
- }
- > psi[1].vaha=6.2
- > print (tab(psi))
- {
- [1] =
- {
- jmeno = "Albert"
- narozen = 2002
- vaha = 6.2
- }
- [2] =
- {
- jmeno = "Chucky"
- narozen = 2003
- vaha = 2.5
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement