# Question:how to replace multiple items in expression without using a loop?

## Question:how to replace multiple items in expression without using a loop?

Maple 2020

Given some expression, I want to replace each exp(.....) in it with something else.

This is what I currently do. First I find all the exp() terms, then using a loop and use subs  like this

```restart;
expr:=1/exp(z)*arcsinh(x*exp(C[1]))+x*sin(exp(x))+3*exp(C[1]*y)*sqrt(sin(exp(3*h)));

#find all exp terms
s:=select(x->has(x,exp),indets(expr));
s:=select(x->op(0,x)='exp',s)```

Now, lets says I want to replace each with Z

I tried to use but that did not work.

So now I am doing this

```for item in s do
expr:=subs(item=Z,expr);
od:
expr```

is it possible do this without a loop? could not do it using ~

With map, I can do this map(x->subs(x=Z,expr),s) but this does not replace it inside expr where I want.

Assignment is not allowed inside the above so I can not do  this map(x->expr:=subs(x=Z,expr),s)

And if I do expr:=map(x->subs(x=Z,expr),s)  it does not work either. it gives

How to do the replacement without using a do loop?

﻿