Last active
January 3, 2016 12:29
-
-
Save kgadek/8463181 to your computer and use it in GitHub Desktop.
Projekt Sauron: interfejs i przykładowy kod zadania typu `background_tasks`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- --------------------------------------------------------------------------------------------------------------------- | |
-- MOCK INTERFEJSU DOSTĘPNEGO NA APPCE | |
-- --------------------------------------------------------------------------------------------------------------------- | |
os = require "os" | |
local android = {} | |
function android.send(self, x) | |
print("ANDROID:SEND:", x) | |
end | |
function android.sleep(self, t) | |
print("ANDROID:SLEEP:", t) | |
os.execute("sleep "..tonumber(t)) | |
end | |
function android.getLatitude(self) | |
local res = 20.019 | |
print("ANDROID:GETLATITUDE >>", res) | |
return res | |
end | |
function android.getLongitude(self) | |
local res = 50.0655 | |
print("ANDROID:GETLLONGITUDE >>", res) | |
return res | |
end | |
function android.getTime(self) | |
local res = os.time() | |
print("ANDROID:GETLLONGITUDE >>", res) | |
return res | |
end | |
-- --------------------------------------------------------------------------------------------------------------------- | |
-- uruchomienie zadania | |
-- --------------------------------------------------------------------------------------------------------------------- | |
function fib(x) return x<2 and x or fib(x-1)+fib(x-2) end | |
local n = 10 | |
for i=0,n do | |
local res = fib(i) | |
android:send(tostring(res)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
W odpowiedzi powinno pojawić się: