Question: I would like to know how can I make the numbers to stay at the textfield of my calculator instead of disappear like when I type 1 then hit the + sign the number 1 disappears from the textfield. I would like to have this (1+1) showing in the text field and also if try to press only + , \* , - , / to show error. My if else statements won't work.

I'm using netbeans I'm start to learn how to program I would like to have some more ideas about programming and some good books.

This is part of my code it is working but not the way that I want to.

```
private void jbtNum1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    display = jtfResult.getText();
    jtfResult.setText(display + "1");
}                                       

private void jbtNum2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    display = jtfResult.getText();
    jtfResult.setText(display + "2");
} 

```

Answer: 
Use a view

```
xs.view.map(f).find(g)

```
Instead of 

```
xs.map(f).find(g)

```

just turn it around

```
xs.find(x => g(f(x)))

```

In both cases `Option[X]` is returned.

---

If you want `Option[Y]`, a recursive method would do the job:

```
  @tailrec
  def findFirst[X, Y](xs: List[X], f: X => Y, g: Y => Boolean): Option[Y] = {
    xs match {
      case Nil =>
        None

      case h :: t =>
        val y = f(h)

        if (g(y)) {
          Some(y)
        } else {
          findFirst(t, f, g)
        }
    }
  }

```