In slide 10 I would like to have a second column which gives abs(first column)

How do I do that?

Thank you very much!

For my future projects, if you have time, can you please explain if you have time

why the extra “a” in definition of the function, do I always need it?

is the backslash just for latex or does it have other meaning here?

and what does ${} generally do, is it referring to a variable defined elsewhere?

You don’t need a variable in simpleFunction (see this post) For simpleFunction, you can put more variables, so if you wanted to do an average rounded to two places, you might use this code:

Note that cellContent takes a string, and simpleFunction returns a number. Keeping track of where you need numbers vs. strings vs. LaTeX is the tricky part. Looking at lots of examples of other code can help there.

The function \abs() is a predefined LaTeX function. So is the \round( , ) used here, and the \frac{ }{ } used at the link. You can see examples of LaTeX symbols here.

Doesn’t your code just display the latex `abs(a)`

for the cellContents? You didn’t actually use your function, `abs`

.

I was just giving a small list of examples.

You stated:

I was clarifying that the code following will not *evaluate* the absolute value.

Good catch, and you’re right! It should have been:

```
abs = simpleFunction("\abs(a)","a")
cellContent(1,2): when this.cellContent(1,1)="" "" otherwise "abs(${this.cellContent(1,1)})"
cellContent(2,2): when this.cellContent(2,1)="" "" otherwise "abs(${this.cellContent(2,1)})"
```

Svetlana fixed it in her activity already. Sorry for the mixup.

Well to evaluate it, it should be

`..."${abs.evaluateAt(this.cellNumericValue(1,1))}"`

That’s right. Argh.

I had this first, then I mangled it. Sorry. I’ve deleted the erroneous posts.

```
abs = simpleFunction("\abs(a)","a")
cellContent(1,2): when this.cellContent(1,1)="" "" otherwise "${abs.evaluateAt(this.cellNumericValue(1,1))}"
cellContent(2,2): when this.cellContent(2,1)="" "" otherwise "${abs.evaluateAt(this.cellNumericValue(2,1))}"
```

I like the simpleFunction better, but I played with another way (link) here:

```
cellContent(1,2): when this.cellContent(1,1)="" "" otherwise "${numericValue("\\operatorname{abs}(${this.cellNumericValue(1,1)})")}"
cellContent(2,2): when this.cellContent(2,1)="" "" otherwise "${numericValue("\\operatorname{abs}(${this.cellNumericValue(2,1)})")}"
```

your original syntax did work, so thank you very much indeed