If it exists, can you tell me the direction?
If it doesn't exist I try read in Inglish, but I'm not sure if then I will can program in CPLua...

Thanks for all.
Posted 11 August 2006 - 11:23 AM
Posted 12 August 2006 - 05:17 AM
Can someone tell me if exists a document about the Lua language in Spanish?
If it exists, can you tell me the direction?
If it doesn't exist I try read in Inglish, but I'm not sure if then I will can program in CPLua...![]()
Thanks for all.
Posted 06 September 2006 - 12:19 PM
Posted 06 September 2006 - 01:54 PM
Posted 10 September 2006 - 02:59 PM
-- defines a factorial function function fact (n) --more lines print("enter a number:") a = io.read("*number") -- read a number print(fact(a))
Posted 10 September 2006 - 03:28 PM
Posted 10 September 2006 - 04:39 PM
Posted 10 September 2006 - 04:49 PM
The book "Programming in Lua" is good to discover the features and possibilities of the Lua language... However you must know that there are a lot of differences with the libraries and packages implemented in CPLua. In CPLua there is no function "io.read()", but instead you have a function "input()" that you could use to ask for a string or a number. The file "functions.txt" lists all the functions that are specific in CPLua
I really need to write something for CPLua beginners...
Posted 10 September 2006 - 06:57 PM
I agree with thatI really need to write something for CPLua beginners...
Posted 13 September 2006 - 10:08 AM
--first with numbers a=1 b=a print(b) --> 1 ok b=2 print(a) --> 1 ok --now with tables a={} a[1]=1 b=a --b is equal to a, but a should remain equal to 1 (for me) print(b[1]) --> 1 ok b[1]=2 --now b=2, but a should remain equal to 1 print(a[1]) --> 2 not ok
Posted 13 September 2006 - 11:57 AM
Posted 13 September 2006 - 12:57 PM
It doesn't sound strange to me; this is exactly what I need as a "general-purpose programmer". Pointer manipulation is one of the most powerful features of this kind of languages.I know it's strange and annoying, but this is how it works.
That's correct... C++ just don't care about matrices. I never need matrix manipulation in my C++ programs, because those are features designed for math programs, and I don't write any math programs myself (like 90% of the other C++ programmers). However, if I somehow need such a feature for my program, I just have to write or import a library to add matrix support, and everything will be fine.Lua is similar to C/C++ in matrix handling; this means that it has very poor matrix support.
I do!(unless you want to create a pointer -- but usually you don't want such a thing)
I agree. People should know what they are exactly doing when manipulating Lua tablesBtw, AFX_Master, you should add such an explanation to your CPLua tutorial.
Posted 13 September 2006 - 05:42 PM
Posted 13 September 2006 - 05:46 PM
Posted 13 September 2006 - 06:20 PM
There is a "powerpatch" to add the "continue" statement in Lua. If several people are interested I can try to apply it on CPLuaand also the fact that the "continue" statement doesn't exist !
If "a" is a table, you should actually think that "a" is only a variable which holds the adress of the real table. Then if you write "b=a", you only copy the table's adress into b, not the table itself. Thus "a" and "b" refer to the same adress and thus to the same table. It's the same thing for functions and userdata's.Ok I think that I have caugth the idea. In Lua, if a and b are tables, when you put a=b it implies b=a & a=b; but if a & b are numbers, a=b doesn't imply b=a. That's it?
"break" is useful to break a loop, while "return" breaks a function.I have a litle question: I understand the function braek, but function return seems to be equal, what is the differences between them??.
function example() -- wait for the user to press left or right arrow while 1 do if testkey(K_RIGHT) then break end -- break the "while" loop when right arrow is pressed else if testkey(K_LEFT) then return "left" end -- return from the function end return "right" endPS: Note that this example is very bad programmed.
function example() -- wait for the user to press left or right arrow local le, ri = false, false repeat le = testkey(K_LEFT) ri = testkey(K_RIGHT) until le==true or ri==true if le==true then return "left" else return "right" end end
Posted 13 September 2006 - 06:26 PM
Btw, AFX_Master, you should add such an explanation to your CPLua tutorial.
Posted 14 September 2006 - 07:50 AM
This argument has been used by all C/C++ programmers worldwide, again and again... I know why; because it's the only argument they can use. Their conclusion is always the same: "I don't need matrices, they don't really exist in C, and I am happy with that; but even if I need them, I can use a matrix library". I totally disagree. What do you mean with "most" programmers? I can reply that most programmers in scientific programming use matrices all the time, because every aspect of Physics or Mathematics is full of matrices.Create implicit copies of matrices would require a lot of time and memory, and most programmers won't need this feature and won't accept to lose time and memory for that
I never (or almost never) use pointers, but I always use matrices.It doesn't sound strange to me; this is exactly what I need as a "general-purpose programmer". Pointer manipulation is one of the most powerful features of this kind of languages.
![]()
That's correct... C++ just don't care about matrices. I never need matrix manipulation in my C++ programs, because those are features designed for math programs, and I don't write any math programs myself (like 90% of the other C++ programmers). However, if I somehow need such a feature for my program, I just have to write or import a library to add matrix support, and everything will be fine.
Posted 14 September 2006 - 08:25 AM
Remember the example I gave earlier: You can have a nice, superfast car, but you will never want to cross the oceans with itscientific programming can be done in C++, but nobody wants to do that, because Fortran 95 is much better for Mathematics. On the other hand, nobody wants to write an operating system in Fortran; it can be done, but C++ can do it much better.
Posted 14 September 2006 - 09:00 AM
Remember the example I gave several months ago: Developing mathematical programs in C++ instead of Fortran 95 is like this: you have a Fiat Panda and a Lamborghini Countach, you want to go from Paris to, say, Moscow, and you take Fiat Panda instead of LamborghiniRemember the example I gave earlier: You can have a nice, superfast car, but you will never want to cross the oceans with it
Programming languages are designed for specific purposes, and they are optimized with consideration for these purposes.
Posted 14 September 2006 - 09:16 AM
Remember the example I gave several months ago: Developing mathematical programs in C++ instead of Fortran 95 is like this: you have a Fiat Panda and a Lamborghini Countach, you want to go from Paris to, say, Moscow, and you take Fiat Panda instead of Lamborghini
.
Posted 14 September 2006 - 09:24 AM
Indeed
This comparison is good for CPBasic and CPLua, because these are languages with the same purposes but with big differences in performance.
Excellent! I totally agree.Suppose Fortran is a car and C++ is a boat
![]()
You can ride from Paris to Moscow with your car, and I can sail from France to USA with my boat.
I can go to Moscow if I want, I just have to add wheels to my boat. But of course I won't be as fast as your car. And you could go from France to USA too, if you add some floats to your car. But I bet you won't be as fast as my boatI think this clearly illustrates the debate
Posted 14 September 2006 - 09:46 AM
Une bonne voiture roule toujours plus vite qu'un bon bateau avec des roues
Posted 14 September 2006 - 12:20 PM
Posted 17 September 2006 - 02:53 PM
require ("draw") pic = pict.new(5,5) draw.onscreen()
Posted 17 September 2006 - 04:44 PM
If you want to use your function in another file than main/name, you must export it explicitely at the end of main/name.For example I create one function, and save it in the folder: main/name; then I want to use this function in other file, I write on the top: require ("main/name"), but the function doesn't work, why?
-- FILE "main/name" function example() print("hello!") end export{example=example} -- exports "example" -- other file: require("main/name") -- imports "example" from main/name example()
pic = pict.new(5,5) is just creating a new picture called "pic". This picture is not drawed at that time. With draw.onscreen() you just indicated that drawing operations must be sent to the screen. But you must use draw.pict() too to make the picture appearOther thing: I create a simple pictur like this:
require ("draw") pic = pict.new(5,5) draw.onscreen()
But nothing apears.. how can I see this pictur in the screen?
require ("draw") pic = pict.new(5,5) draw.onpict(pic) -- draw on the picture draw.rect(0,0,4,4) draw.onscreen() -- now draw on the screen draw.pict(10,10,pic) -- make the pict appear
Posted 18 September 2006 - 12:56 PM
require ("draw") pic = pict.new(5,5) draw.onpict(pic) -- draw on the picture draw.rect(0,0,4,4) draw.onscreen() -- now draw on the screen draw.pict(10,10,pic) -- make the pict appear
Posted 18 September 2006 - 01:52 PM
Then add this at the end:Ok the function in other file works perfect with export. Sorry, but I write this code, and nothing apears, only Done.
showgraph() -- show the graph window waitinput() -- wait for a key
Posted 02 October 2006 - 08:36 PM
require('LNA/TrapAd') function f(x) return math.exp(3*x) end q=TrapAdapt(f,0,3) print(q)
Posted 02 October 2006 - 09:47 PM
As far i know, the Storage RAM (415108 bytes free) is totally independant from calculation RAM (1.2 mb in O.S 2.2). when the memory fills up, you see an "Alloc Failed" message, sure, isn't memory problemCan it be the memory?? what can I do? I have 415108 free bytes, I think it is sufficient.
*In spanish: que se me cuelga
Posted 03 October 2006 - 04:39 PM
Posted 03 October 2006 - 07:15 PM
If I undestand Storage RAM doesn't affect to calculation speed, but calculation RAM yes
Hey, it was 180 Kb in CPLua 0.9B, it's now 1.2 Mb in the current version, and you still want more?and is 1,2 mb in OS 2.2. This calculation RAM is always 1,2?? There are any form to increase this calculation RAM??
Posted 03 October 2006 - 09:32 PM
Hey, it was 180 Kb in CPLua 0.9B, it's now 1.2 Mb in the current version, and you still want more?
Posted 04 October 2006 - 06:01 PM
p=0.3-0.4 h=1.2-1.3 print(p==h) --> false ?????????? :banghead: p=0.7-0.8 print(p==h) --> true ok
Posted 04 October 2006 - 07:18 PM
According to the developer (Orwell), CPLua is in version 0.9D. If I understand well, this is a pre-pre release candidate.When we can get CPLua 0.9? And LUA 1.7? Or it's now available and I had not found out? (I only ask, you can get your time)
Posted 05 October 2006 - 09:19 PM
p=0.3-0.4 h=1.2-1.3 print(p==h) --> false ??????????
Posted 06 October 2006 - 07:49 AM
require("cas") A = cas("0.3") B = cas("1.2") print( (A-0.4)==(B-1.3) ))
Posted 06 October 2006 - 02:35 PM
Posted 06 October 2006 - 09:06 PM
(Sorry for answering late, but I didn't noticed your post before)One problem whit LUA, in this code:
require('LNA/TrapAd') function f(x) return math.exp(3*x) end q=TrapAdapt(f,0,3) print(q)My class pad 300 doesn't respond, (it's many time thinking and nothing is shown)* I think it's wouldn't have to be difficult for LUA, if I use Romberg instead TrapAdapt happens the same.
Can it be the memory?? what can I do? I have 415108 free bytes, I think it is sufficient.
Yes, it is normal, for the same reason. Note that Romberg is in general faster and more accurate than TrapAdapt, but not always (read the manual for details). Set eps=0.01 to get a very accurate result easily.Ok I wait more time and the class pad takes 2 min, more or less, to do Romberg(f,0,3); f=e^(3x). Is it normal??
It is faster if I change function, for example: f=1/((1-x)*(0.05+0.5*x))
I like your sense of humor, although "MicroSystems" reminds me Micro..ft, which is disgusting.Wait for PAP, he's the owner of PAP MICROSYSTEMS, and he could help you.
PD: Hey PAP, what about state PAP MICROSYSTEMS, joke
Posted 07 October 2006 - 12:13 PM
--> PS: I think that you should post those questions to the LNA topic. LNA is a library written in CPLua; it's not part of the Lua language.
0 members, 1 guests, 0 anonymous users