if else operation with two waves

Hi everybody,
I am still new to igor so I'll hope you can help me:
I would like to implement a conditional statement on one wave which leads to a change in another:
so I have two waves: C13factor and Br79_normC13:

if C13factor >1 the following operation shall be done: Br79_normC13*(1-(abs(1-C13factor)))
if C13factor <1: Br79_normC13*(1+(1-C13factor))

This is how my code looked so far but the outcome wave Br79_normC13 hasn't the right numbers.


if (C13factor>1)
Br79_normC13=Br79_normC13*(1-(abs(1-C13factor)))
else
Br79_normC13=Br79_normC13*(1+(1-C13factor))
endif
Take a look at conditional operators for wave assignments.

Br79_normC13[] = (C13Factor[p] > 1) ? Br79_normC13[p]*(1-(abs(1-C13factor[p]))) : Br79_normC13[p]*(1+(1-C13factor[p]))


I think this is what you want. Note that C13Factor == 1 is dealt with as C13Factor < 1.
The ternary operator (? :) is great but sometimes too messy. In that case, you would need to avoid assigning to the entire wave Br_normC13.
You would need something like:

variable i, n=numpnts(C13factor)
for (i=0; i<n; i+=1)
        if (C13factor[i]>1)
            Br79_normC13[i]=Br79_normC13[i]*(1-(abs(1-C13factor[i])))
        else
            Br79_normC13[i]=Br79_normC13[i]*(1+(1-C13factor[i]))
        endif
endfor


After writing the above I realized there's also another easy way,

variable np=numpnts(C13factor)
make /o/np ifthenthis= Br79_normC13*(1-(abs(1-C13factor)))
make /o/np ifelsethis= Br79_normC13*(1+(1-C13factor))
Br79_normC13[]= C13factor[p]>1 ? ifthenthis[p] : ifelsethis[p]