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

**URL:** https://racket.discourse.group/t/how-can-i-nest-an-expression-to-use-resulting-function-only-once/791
**Category:** Questions & Answers
**Tags:** question, drracket, typed-racket
**Created:** [March 13, 2022, 11:32am UTC](https://racket.discourse.group/t/how-can-i-nest-an-expression-to-use-resulting-function-only-once/791 "2022-03-13T11:32:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![osman44](https://avatars.discourse-cdn.com/v4/letter/o/85f322/32.png) [@osman44](https://racket.discourse.group/u/osman44)
#### Post date: [March 13, 2022, 11:32am UTC](https://racket.discourse.group/t/how-can-i-nest-an-expression-to-use-resulting-function-only-once/791/1 "2022-03-13T11:32:57Z")

</div>

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)]))

---

<div class="post-metadata">

### Author: ![capfredf](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/capfredf/32/935_2.png) [@capfredf](https://racket.discourse.group/u/capfredf)
#### Post date: [March 13, 2022, 11:45pm UTC](https://racket.discourse.group/t/how-can-i-nest-an-expression-to-use-resulting-function-only-once/791/2 "2022-03-13T23:45:11Z")

</div>

This is one possible solution:

```scheme
(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`
