
Сообщение от
krt17
Ну и до кучи Lua демо
Попробовал перевести на PureBasic. Получается что-то не то...
PHP код:
Global Dim Pattern.l(16,16)
Procedure elem(n,y,x)
; Print( Str(n) )
; Print( Str(x) )
; PrintN( Str(y) )
If n=1
ProcedureReturn Pattern(y+1,x+1)
Else
ProcedureReturn elem(n-1, Round(y/2,#PB_Round_Down), Round(x/2,#PB_Round_Down)) + elem(1, y%2, x%2) * Pow(4,(n-1))
EndIf
EndProcedure
OpenConsole("")
; Pattern={{3,1},{0,2}}
Pattern(0,0) = 3
Pattern(0,1) = 1
Pattern(1,0) = 0
Pattern(1,1) = 2
cur = 3
For y=0 To Pow(2,cur-1)
Print( Str(y) ); io.write (y.."\t")
For x=0 To Pow(2,cur-1)
Print( Str(elem(cur,y,x)) ); io.write (elem(cur,y,x).."\t")
elem(cur,y,x)
Next x
PrintN(""); io.write ("\n")
Next y
CallDebugger