Advertisement
WarPie90

Untitled

Jun 4th, 2018
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. print "Let's do this shit!!"
  2. func prime(lim)
  3.   var n := 1
  4.   var primes := 0
  5.   while(n < lim) do
  6.     var k := 3
  7.     var is_prime := True
  8.     n += 2
  9.     while (is_prime and k * k <= n) do
  10.       is_prime := n div k * k != n
  11.       k += 2
  12.     end
  13.     if(is_prime) primes += 1
  14.   end
  15.   return n
  16. end
  17.  
  18. var i:=0;
  19.  
  20. func sqr(x) => x*x
  21.  
  22. for i:=0; i<5; i++ do
  23.   print sqr(i)
  24. end;
  25. print '-----------------------'
  26.  
  27.  
  28. i := 0.0
  29. while (i++ < 3) print sqr(-i);
  30. print '-----------------------'
  31.  
  32.  
  33. var myPrimeFunc := prime
  34. print myPrimeFunc(5000)
  35. print '-----------------------'
  36.  
  37.  
  38. var myfoo := None
  39. if(myfoo) print 'foo!'; else print 'no foo!'
  40.  
  41.  
  42. myfoo := not myfoo
  43. if not myfoo then
  44.   print 'no foo'
  45. else
  46.   print 'foo!'
  47. end
  48.  
  49. for var i:=0; i < 5; i++ do
  50.   var foo := 10;
  51.   print foo;
  52.   var foo := False; //redeclare
  53.   print foo;
  54.   foo := True;
  55.   print foo;
  56. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement