Answer the question
In order to leave comments, you need to log in
What is the correct way to call a function?
I decided to drag the code into an external method and everything fell apart.
what is the right way to put f into the parabol parameter? or other ways to correctly call a function without errors.
func f(x: Double) -> Double {
return x*x
}
func parabol() -> Void {
var : Double = 1e-6
var x = [Double]()
x.append(3)
x.append(4)
x.append(5)
// Cannot call value of non-function type '[Double]'
var f = [Double]()
f.append(f(x: x[0]))
f.append(f(x: x[1]))
f.append(f(x: x[2]))
}
func parabol() -> Void {
// Type of expression is ambiguous without more context
x.sort { (one, two) in return f(x: one) < f(x: two) }
}
Answer the question
In order to leave comments, you need to log in
func f(x: Double) -> Double {
return x*x
}
var x = [Double]()
func parabol() {
//var g: Double = 1e-6
x.append(3)
x.append(4)
x.append(5)
// Cannot call value of non-function type '[Double]'
var y = [Double]()
y.append(f(x: x[0]))
y.append(f(x: x[1]))
y.append(f(x: x[2]))
}
func parabolN() {
// Type of expression is ambiguous without more context
x.sort { (one, two) in return f(x: one) < f(x: two)
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question