INCOMPLETE FUNCTION (end) error

I keep getting the error ‘syntax: incomplete: “function” at none:2 requires end’ but when I check all my fucntions have an ‘end’. Kindly show me where the error is how to correct it. Here is the code:

function Combination(n, k)
   #number combination n,k
    return factorial(n)/(factorial(n-k) * factorial(k))
end

# calculate binomials
#binomial = [[int(Combination(n, k)) for k in range(0, stop=n+1, length=100)] for n in range(0, stop=20, length=100)]

function  B(n, i, t)
   # polynomial berstein
    return binomial[n][i] * (t^i) * (1-t)^(n-i)
end 

function  Bezier(t, points)
    #realisation polynomial bezier curve
    n = len(points)
    res =zeros_like(points[0])
    for (i, point) in enumerate(points)
        res += B(n-1, i, t) * point
    return res
end 

function  Bezier3(t, points)
    #matrix cubic bezier curve
    points =[points]
    res = ([1, t, t^2, t^3] *[[1, 0, 0, 0]*[-3, 3, 0, 0]*[3, -6, 3, 0]*[-1, 3, -3, 1]])
    res = (res*points)
    return res
end 
    
function Bezier2(t, points)
    #matrix quadratic bezier curve
    points = [points]
    res = ([1, t, t^2]* [[1, 0, 0]*[-2, 2, 0]*[1, -2, 1]])
    res = (res*points)
    return res
end
    
points = [(5.0, 2.0), (-2.0, 3.0), (-1.0, 4.0), (4.0, 5.0)]
points = [points]

T = range(0, stop=1, length=1000)
# test universal time
@time Bs =([Bezier(t, points) for t in T]).T
# vs time matrix realisation
@time  Bs3 = ([Bezier3(t, points) for t in T]).T

Please quote your code: PSA: how to quote code with backticks, it’s (almost) impossible to help otherwise.

2 Likes

It seems you are missing end to close the for loop in Bezier(t, points) function.

1 Like