24 авг. 2008 г.

Луна

18 июл. 2008 г.

Lua: Динамический список возвращаемых значений без создания таблицы

Задача
print(
tvalues(
{ a = 1, b = 2, c = 3 },
"a", "b", "xxx", "c", "yyy"
)
)
--> 1 2 nil 3 nil

Типичное решение требует создания таблицы:
function tvalues(t, ...)
local n, r = select("#", ...), { }
for i = 1, n do
t[i] = t[select(i, ...)]
end
return unpack(r, 1, n)
end

Shmuel Zeigerman посоветовал использовать следующий рекурсивный подход:
function tvalues(t, ...)
local key = (...)
if key ~= nil then
return t[key], tvalues(t, select(2, ...))
end
return nil
end

24 мая 2008 г.

ОО

Анонс. Передача Виртуалити, выпуск 11, часть 2. 29.08.2007

Видео здесь (1:32 -- 2:10):

http://games-tv.ru/v/397

20 мая 2008 г.

out-35-10-all.txt

Typifying crackled tenacious colossal avenues.
Manhandling wobbled, poisonous.
Sledding crewing balloons.
Idyllic!

13 мая 2008 г.

Экспорт списка контактов из Adium'а на AppleScript'е

Странная всё-таки штука этот AppleScript...

tell application "Adium"
set fileName to choose file name default name "AdiumContacts.txt"
set fileHandler to open for access fileName with write permission
try
set allContacts to every contact
repeat with oneContact in allContacts
write ?
"\"" & (title of account of oneContact as text) & "\", " & ?
"\"" & (title of oneContact as text) & "\", " & ?
"\"" & (display name of oneContact as text) & "\", " & ?
"
" to fileHandler
end repeat
on error errStr number errorNumber
close access fileHandler
error errStr number errorNumber
end try
close access fileHandler
end tell