Scripting competition

Brian Yennie briany at qldlearning.com
Tue May 12 02:12:21 EDT 2009


Clearly I have a problem. Key features include never initializing  
variables (let alone declaring them), loads of obscure string handling  
hacks to cram everything into fewer variables, and overall headache- 
inducing clutter.
You can actually use this one with 1 parameter, or pass 2 for a list  
of all Fibonacci numbers between n1 and n2. Somewhat surprisingly,  
it's still pretty fast!

fb(10) = 55
fb(1,10) = 1,1,2,3,5,8,13,21,34,55

function fb n1,n2
    repeat max(n1, value("0"&n2)+1) + 1
       repeat with i=-1 down to (0 - max(1,length(item -1 of xy)) - 1)
          put (offset(char i of item -2 of xy,"123456789") + max(1 -  
min(1,length(xy)),offset(char i of item -1 of xy, "123456789")) +  
offset(c, "1")) mod 10 into char i of s
          put (offset(char i of item -2 of xy,"123456789") + max(1 -  
min(1,length(xy)),offset(char i of item -1 of xy, "123456789")) +  
offset(c, "1")) div 10 into c
       end repeat
       put ((offset(xy, "xy") & (char (1 + min(2, offset(xy, "!xy")))  
to -1 of item -1 of xy)) + 0)&comma&(s+0) into item -1 of xy
    end repeat
    return item (n1+2) to (max(n1, value("0"&n2))+2) of xy
end fb





More information about the use-livecode mailing list