mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Avoid dynamic allocation and useless string copy by keeping the
importation status flag in the areaBuffer
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
|
||||
namespace Code {
|
||||
|
||||
constexpr ScriptTemplate emptyScriptTemplate(".py", R"(from math import *
|
||||
constexpr ScriptTemplate emptyScriptTemplate(".py", "\x01" R"(from math import *
|
||||
)");
|
||||
|
||||
constexpr ScriptTemplate factorialScriptTemplate("factorial.py", R"(def factorial(n):
|
||||
constexpr ScriptTemplate factorialScriptTemplate("factorial.py", "\x01" R"(def factorial(n):
|
||||
if n == 0:
|
||||
return 1
|
||||
else:
|
||||
return n * factorial(n-1))");
|
||||
|
||||
constexpr ScriptTemplate fibonacciScriptTemplate("fibonacci.py", R"(def fibo(n):
|
||||
constexpr ScriptTemplate fibonacciScriptTemplate("fibonacci.py", "\x01" R"(def fibo(n):
|
||||
a=0
|
||||
b=1
|
||||
for i in range(1,n+1):
|
||||
@@ -27,7 +27,7 @@ def fibo2(n):
|
||||
return 1
|
||||
return fibo2(n-1)+fibo2(n-2))");
|
||||
|
||||
constexpr ScriptTemplate mandelbrotScriptTemplate("mandelbrot.py", R"(# This script draws a Mandelbrot fractal set
|
||||
constexpr ScriptTemplate mandelbrotScriptTemplate("mandelbrot.py", "\x01" R"(# This script draws a Mandelbrot fractal set
|
||||
# N_iteration: degree of precision
|
||||
import kandinsky
|
||||
def mandelbrot(N_iteration):
|
||||
@@ -47,7 +47,7 @@ def mandelbrot(N_iteration):
|
||||
# Draw a pixel colored in 'col' at position (x,y)
|
||||
kandinsky.set_pixel(x,y,col))");
|
||||
|
||||
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", R"(from math import *
|
||||
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", "\x01" R"(from math import *
|
||||
# roots(a,b,c) computes the solutions of the equation a*x**2+b*x+c=0
|
||||
def roots(a,b,c):
|
||||
delta = b*b-4*a*c
|
||||
|
||||
Reference in New Issue
Block a user