How can i nest an expression to use resulting function only once?

I am trying to nest this already designed function ,so the function place-image is only used once,however,i have tried different ways but i keep getting errors,this is the closest i could get to but it returns an error define:

expected only one expression for the function body, but found 1 extra part

(place-image (cond [(> h ROCKET-CENTER-TO-TOP)]) ROCKET 50 h MTSCN) [else ROCKET 50 ROCKET-CENTER-TO-TOP MTSCN])

can someone help me better format this code

(define (create-rocket-scene.v5 h)
(cond
[(<= h ROCKET-CENTER-TO-TOP)
(place-image ROCKET 50 h MTSCN)]
[(> h ROCKET-CENTER-TO-TOP)
(place-image ROCKET 50 ROCKET-CENTER-TO-TOP MTSCN)]))

This is one possible solution:

(apply place-image
(cond
[(<= h ROCKET-CENTER-TO-TOP)
(list ROCKET 50 h MTSCN)]
[(> h ROCKET-CENTER-TO-TOP)
(list ROCKET 50 ROCKET-CENTER-TO-TOP MTSCN)]))

(I am on mobile. There could be typos)

You can also call-with-values

2 Likes