In python it s possible to type :

from math import *

cos( pi - 4.0 )

instead of

import math

math.cos(math.pi /4.0)

is there a way to to simplify syntax in codea too ?

thanks

In python it s possible to type :

from math import *

cos( pi - 4.0 )

instead of

import math

math.cos(math.pi /4.0)

is there a way to to simplify syntax in codea too ?

thanks

maybe this?

```
function setup()
inportAllFrom(math)
print(cos(pi/4))
end
function inportAllFrom(tb)
for key,func in pairs(tb) do
if _G[key]==nil then _G[key] = func end
end
end
```

merci

it works fine but it’s enigmatic

not enigmatic:

1/ _G is the table of all global variables in lua.

2/ and `math`

is just a regular table.

3/ so i simply copy all fields of math into _G, making them global…

4/ i test for nil bacause there is an strange tween error otherwise, because `math.type`

is different from `type`

, and probably used by a hidden internal tween function call.

Is it clear now?

@hpsoft not sure if this is what you’re asking, but you can assign variables to any Codea/Lua function to act as a shortcut, eg

`cos = math.cos`

, or `local cos = math.cos`

, and then `y = range * cos(angle)`

or whatever. [edit]: this is doing exactly the same as @Jmv38 's code, just on a piecemeal basis, whereas his is comprehensive for an entire area.

@hpsoft - you can also modify or replace standard functions, eg to make the sin function work with degrees instead of radians

```
local ss=math.sin
local f=math.pi/180
sin=function(x) return ss(x*f) end
--now you can calc sin like this
V=sin(45)
```