[Question]
  [
My stovetop has 10 (0 through 9) different settings of heat and a very odd way of cycling through them.
* It always starts at 0
* When I hit plus it increments the number, *unless* the number is 9 in which case it becomes 0, or the number is 0 in which case it becomes 9.
* When I hit minus it decrements the number, *unless* the number is zero in which case it becomes 4.
There are no other temperature control buttons.
In this challenge you will take as input a string of commands and output which setting my stovetop ends up on after running that sequence.
Answers will be scored in bytes with fewer bytes being better.
## Input
You may take input in any of the following formats:
* A list/array/vector/stream of booleans/1s or 0s/1s or -1s
* A string (or list/array/vector/stream) of two different characters (which should be consistent for your program)
And you may output
* An integer on the range 0-9.
* A character on the range '0'-'9'.
* A string of size 1 consisting of the above.
## Testcases
Input as a string `-` for decrement and `+` for increment.
```
 : 0
- : 4
+ : 9
-- : 3
-+ : 5
+- : 8
++ : 0
--- : 2
--+ : 4
-+- : 4
-++ : 6
+-- : 7
+-+ : 9
++- : 4
+++ : 9
---- : 1
---+ : 3
```
  
[Answer]
# JavaScript (ES6), ~~38 37~~ 36 bytes
Expects an array of Boolean values, with *false* for `+` and *true* for `-`. Returns an integer.
```
a=>a.map(c=>a=a++?c?a-2:a%10:9>>c)|a
```
[Try it online!](https://tio.run/##Zc7LDoIwEAXQPV8xITHQTFpUfEFS/BDjYlLBaBCIJa78d@Th1KhdNad35vZKD7LmfmlaWdWnvCt0RzojdaMmNP1FE@Le7EkuU5ot5mmSZUY8qWtz24IGCzoDU1e2LnNV1uewCA9KKXucFoyvoDUEMhBCeN4wFvo@9EdAFMH8LdJnWb0FnSScGUKjxCzIsuYpl9mxuIzrGhaNsnSC/ne7RPknnNm4Ls5snXAmce2/exB/M3L40CiLj@AkcfcC "JavaScript (Node.js) – Try It Online")
### Commented
It's important to note that `a++` with `a = [ true ]` is evaluated to `NaN` because it's first coerced to the string `"true"` and then to a number. That's why we can safely re-use the array `a[]` to store the temperature even when we get the singleton `[ true ]` as input.
```
a =>             // a[] = input array, re-used to store the temperature
  a.map(c =>     // for each command c in a[]:
    a =          //   update the temperature:
      a++ ?      //     if a is numeric and not equal to 0
                 //     (increment it afterwards):
        c ?      //       if this is a '-':
          a - 2  //         subtract 2
        :        //       else:
          a % 10 //         apply a modulo 10
      :          //     else:
        9 >> c   //       yield 4 if this is a '-', or 9 if this is a '+'
  ) | a          // end of map(); return the final result
```
[Answer]
# [PHP](https://php.net/), ~~103~~ ~~90~~ ~~86~~ ~~75~~ 71 bytes
```
while($k=$argv[1][$i++])--$k?$p?$p++<9?:$p=0:$p=9:($p--?:$p=4);echo+$p;
```
[Try it online!](https://tio.run/##K8go@G9jXwAkyzMyc1I1VLJtVRKL0suiDWOjVTK1tWM1dXVVsu1VCoBIW9vG0t5KpcDWAERYWmmoFOjqggVMNK1TkzPytVUKrP///28EAA "PHP – Try It Online") - Add string as argument - 1 for `-`, 2 for `+`. Example: for `---+`, `1112`.
Thanks to @Kaddath for -13 bytes (see comment). -4 by changing input format to 0/1. -11 thanks to @640KB. -4 thanks to @DewiMorgan.
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~58~~ \$\cdots\$ ~~56~~ 54 bytes
```
t;f(*s){for(t=0;*s;)t=*s++-7?t?t-1:4:t?-~t%10:9;*s=t;}
```
[Try it online!](https://tio.run/##XVHLboMwELznK1ZISAZsFfJoGhw3h6pf0eRAiUlQUxJhV0WN6KeX@gWlscAsOzO743VO8lNWHbpO0gKFIrgW5xpJFtNQ0ECyUEQRWW7kRpIknadyQ76ln8TpSuFM0rYrKwnvWVmhYHKdgFr5MatDkFxI8bIDBlfPw@ARvUUmMiExcWTTLm8Bi5DI0RzPEp2ql/U6J1RoS40HbYo3F55LvrcmYgxzDCsMMwwLDA8YVGZqkuq5x7A0qOUkiuYq2dPkR56/8dqdZ9s8T7fN6km9C9159D/rHagpAtI2ymrPGyWLqQvXIMovfi5QbzC4c4lwyFCIIsMOwA51NFhVyw7XEHZ0wHW3E68ULmStAiSD/@DrR1G8aEYEyUj3Z9XZhDXThYyJYKDpZSqUegrSfBjMZ7CBJaQmMaqJNPWmv1C63sONb66g4cJuD3apFaVAni@APIK/B19sKzV4iUHg4W4EY3znOraTtvvJi1N2EB35/AU "C (clang) – Try It Online")
*Saved ~~a~~ 3 bytes thanks to [Johan du Toit](https://codegolf.stackexchange.com/users/41374/johan-du-toit)!!!*
Inputs a string of minuses and ~~pluses~~ bell-characters (ASCII 7) and returns the stovetop temperature in the input string (right at the end where the `'\0'` terminator would have been).
[Answer]
# [Rust](https://www.rust-lang.org/), 46 bytes
```
|x|x.fold(0,|u,v|if u>0{u-v*2+1}else{9>>v}%10)
```
[Try it online!](https://tio.run/##XY3vCoIwFMW/@xQ3Idhq1db/CHyRiBC7kmAmcxPD@ew2jcr1aef87tk5UheqjTO4h0lGaO2dSoxGpzOD/uUfIb6E8Z/8UvGjoqPeJztMD/JWOj1O07DL2XBX/nbcpe7feZ4olITO72FOTGUqxz@NmD3p27T9NX6kV8KZ0aw0SQw64LWelZPlVDSYFlgfgqBsxoLTltqsvGAY3breXCaZGhG/bsBnFaVH6EmaWeZxWMMBVrCBPXBYWreGLews67iAlW/ziwVglWOk8AoSC50qr2lf "Rust – Try It Online")
Takes an `Iterator` of zeros (for `+`) and ones (for `-`), and returns the resulting stove temperature. Taking -1s and 1s doesn't seem to help, because `(-1,1) -> (4,9)` isn't trivial to represent in integer arithmetic.
Uses [Arnauld's input method and bit-shift trick](https://codegolf.stackexchange.com/a/218367/78410) for the zero case. Also, Rust's if-else expression can be a part of larger expression, so `%10` is factored out to avoid the parentheses in `(u-v*2+1)%10`.
[Answer]
# [convey](http://xn--wxa.land/convey/), 41 bytes
Takes in a list of 0 for + and 1 for -.
```
  }{
0>?@`"+1
^ 1-0=v
`15|8*v
|<<,<+<
^10
```
[Try it online!](https://xn--wxa.land/convey/run.html#eyJjIjoiICB9e1xuMD4/QGBcIisxXG5eIDEtMD12XG5gMTV8OCp2XG58PDwsPCs8XG5eMTAiLCJ2IjoxLCJpIjoiMSAxIDAifQ==)
[![stove](https://i.stack.imgur.com/mUhpA.gif)](https://i.stack.imgur.com/mUhpA.gif)
`a` loops around and based on the input `}` goes `@` down towards `-1` and mod 15 `|15` (to set -1 to 14), or goes to `+1` and `+ ((a=0) * 8)` – thus gets set to 9 if `n` was 0. We join both paths `,` and with mod 10 `|10` we get 14 -> 4, 10 -> 0. If the input is empty, `a` goes on `?` to the side path to the output `}`.
(The `^` next to the 10 shouldn't be necessary, but I haven't fixed the bug yet.)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~16~~ ~~15~~ ~~14~~ 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
Input as a list of `-1`/`1` for `-`/`+` respectively.
```
ÎvD_Ƶ≠yè*yOθ
```
[Try it online](https://tio.run/##yy9OTMpM/f//cF@ZS/yxrY86F1QeXqFV6X9ux///0YY6uoY6hrEA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waf@oYZ6udmXK4RVeSgoah/drKjxqm6SgZP/foLLMJf7Y1kedCyoPr9Cq9D@343@tjmbM/@joWJ1oXUMgYQhm6OhCabAQhAfhgOXg0rpwQSQtcE0wfXBzECahmIVsHFhtLAA).
**Explanation:**
```
Î             # Push 0 and the input-list
 v            # Loop `y` over the input-list:
  D           #  Duplicate the current value
   _          #  Pop the copy, and check that it's 0 (1 if 0; 0 otherwise)
    Ƶ≠        #  Push compressed integer 185
      yè      #  Index `y` into it (0-based modulair, so the leading 1 is ignored, while
              #  1→8 and -1→5)
        *     #  Multiply it to the ==0 boolean
         y    #  Push `y`
          O   #  Take the sum of the three values on the stack
           θ  #  And only leave the last digit (for 10→0)
              # (after the loop, the value is output implicitly as result)
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `Ƶ≠` is `185`.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 33 bytes
```
^
0
{T`+09d`_9d`^.\+
T`-d`_4d`^.-
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wP47LgKs6JEHbwDIlIR6I4/RitLlCEnSBPBMQT/f/fwUrBQMuXSBpwqUNJC25dEEcYy5dEM@USxvEs@DS1oaoA0saAWltsA5dbV0oDeKbAVWD@OZAGmKWNlReWxtmNliBIYgBEjEGAA "Retina 0.8.2 – Try It Online") Link includes test suite. Explanation:
```
^
0
```
Start with heat setting 0.
```
{
```
Process all of the control buttons.
```
T`+09d`_9d`^.\+
```
If the control button is a plus, then delete it (by transliterating to `_`) and cyclically increment the digit (`T`9d`d` is the standard way to cyclically increment digits) but change `0` to `9` instead by listing it as an exception before the expansion of `d` to `0123456789`.
```
T`-d`_4d`^.-
```
If the control button is a minus, then delete it and decrement the digit, but use `4` instead of the usual `9` for cyclic decrement.
[Answer]
# [Coconut](http://coconut-lang.org/), 39 bytes
Takes input as a list of `1/-1`
```
reduce$((p,k)->[k%7-2,p+k][p>0]%10,?,0)
```
[Try it online!](https://tio.run/##PY3LbsIwEEX3/opZgGxrbBQehRaJ9Ce6oyxCcFQrIVh@qAvKt6eehHYzd@7MmTv1rb71KQ7N4XPw5pJqMxPCqVbq8tjOd3qlHLanoyuL03xZqHdVyOH7y3YGPnwyewZQKTjDAWzvUhQSfkpYBNfZKDjsgctMeBNSFzNT0fZauRlwQL5obH@hSWdDJG0oLQTj4/8J5UZxphTnqW34vXqALuE@IQ8uh/ynYDrXDcNc35gms2aa3AtDcq8MceLG5Sorjhca9VPJbzNNfpd1ysLnHvEvewSW1NBk/Qs "Coconut – Try It Online")
This uses `((-1)%7-2)%10 = (6-2)%10 = 4` and `(1%7-2)%10 = (-1)%10 = 9`, which works because in Python the result of the modulo operation has the same sign as the divisor.  
`-k%-7` would work instead of `k%7-2` and is one byte shorter if we swap `-1` and `1` in the input, but that feels like abusing the input format.
[Answer]
# [J](http://jsoftware.com/), 24 bytes
Takes `-1` for `-` and `1` for `+`.
```
0(10|15|++8*0=<.)/@|.@,]
```
[Try it online!](https://tio.run/##ZY8xDsIwDEX3nMJicYvrkACFEqiEhMTExIo6IVpg4QIVVw@taJwhQwY/fb/vvP1MYwu1A4QCDLjhsYbT9XL2JrOmt2VPVM1NfdD54tjrY9H4XKluXLm5Fix/ARkIX7pR6nF/fiDbd/nAmAknMjgddIAI/3k9zRzAbgIUwCokJFIGIpkqLEkm9JBkluLhpDyaBEXVRpCkttKX3p26iNJUdNl4F6d/Hm3@Bw "J – Try It Online")
```
0(10|15|++8*0=<.)/@|.@,]
0                    @,] prepend a 0 and …
                  @|.    rotate and …
 (              )/       fold from the left:
            0=<.         if the minimum of the step and the accumulator is 0
                           (can only happen if they are 1/0)
         +8*             add 8 to …
        +                the sum of the step and the accumulator
     15|                 mod 15 to get -1 -> 14
  10|                    mod 10 to get 10 -> 0, and 14 -> 4
```
[Answer]
# [Python 2](https://docs.python.org/2/), 50 bytes
```
n=0
for b in input():n=[b%7-2,n+b][n>0]%10
print n
```
[Try it online!](https://tio.run/##K6gsycjPM/qfnJ@SaqukpPQ/z9aAKy2/SCFJITMPiApKSzQ0rfJso5NUzXWNdPK0k2Kj8@wMYlUNDbgKijLzShTy/gO1cZVnZOakKhhapVakJiuADPsfHcsVrWsIJAzBDB0FXRgDLAjlQ7kQeSQ1ukgSKHqRtCOMQDIV2WB0s9HMh@gCAA "Python 2 – Try It Online")
Takes input as ±1's. Pretty explicitly fixes the `n=0` case to have `b=-1` give `4` and `b=1` give `9`. There's probably a better way.
**50 bytes**
```
n=0
for b in input():n=((n or 9-b%5)+b)%10
print n
```
[Try it online!](https://tio.run/##K6gsycjPM/qfnJ@SaqukpPQ/z9aAKy2/SCFJITMPiApKSzQ0rfJsNTTyFICilrpJqqaa2kmaqoYGXAVFmXklCnn/gdq4yjMyc1IVDK1SK1KTFUCG/Y@O5YrWNQQShmCGjoIujAEWhPKhXIg8khpdJAkUvUjaEUYgmYpsMLrZaOZDdAEA "Python 2 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~45~~ 37 bytes
```
0#1=9
0#a=4
9#1=0
x#a=x+a
f=foldl(#)0
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/30DZ0NaSy0A50daEyxLINuCqALIrtBO50mzT8nNScjSUNQ3@5yZm5tkWFGXmlaikRRvqKACRLhQbxv4HAA "Haskell – Try It Online")
* Saved 8 thanks to @Wheat Wizard
[Answer]
## [R](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjPp-ngrtDuAhUwy4UKHXuIDPQQFjAAegQIARAD&url=https%3A%2F%2Fcran.r-project.org%2F&usg=AOvVaw0pGNScRjIdSkNXK6Ky1j_m), ~~57~~ 55 bytes
```
f=function(x){for(i in x)F=(F+i)%%10+"if"(i>0,8,-5)*!F;F}
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP0@jQrM6Lb9II1MhM0@hQtPNVsNNO1NTVdXQQFspM01JI9POQMdCR9dUU0vRzdqt9n@aRnFibkFOqkayhq6hjqGmjqGBqZlOUWqBbUhQqKumJleaBpCjYahjAWeD1EF4yRogLZr/AQ "R – Try It Online")
[Answer]
# [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), ~~47~~ 43 bytes
Expects each operation on a separate line with `+` for increment and `-` for decrement
```
/-/{a?a--:a=4}/+/{a=a?++a%10:9}END{print+a}
```
[Try it online!](https://tio.run/##SyzP/v9fX1e/OtE@UVfXKtHWpFZfG8izTbTX1k5UNTSwsqx19XOpLijKzCvRTqz9/1@XSxsBAQ "AWK – Try It Online")
[Answer]
## x86-16 machine code, 40 bytes
Port of @Arnauld's answer. Be sure to upvote him! (Example run is unneccecary since it's just a port.)
```
0BAC:0100  31 DB E3 23 AC 84 DB 74-14 84 C0 75 04 FE CB EB   1..#...t...u....
0BAC:0110  14 FE C3 89 D8 B7 0A F6-F7 88 C3 EB 08 B3 09 86   ................
0BAC:0120  C8 D2 EB 86 C8 E2 DD C3                           ........
```
Callable function.
Expects `[SI]` = index of list (0x00 for `-`, 0x01 for `+`), `CX` = length of list.
Needs a spare `AX`.
Function output is to `BL` (accumulator value).
Disassembled:
```
0BAC:0100 31DB          XOR     BX,BX
0BAC:0102 E323          JCXZ    0127
0BAC:0104 AC            LODSB
0BAC:0105 84DB          TEST    BL,BL
0BAC:0107 7414          JZ      011D
0BAC:0109 84C0          TEST    AL,AL
0BAC:010B 7504          JNZ     0111
0BAC:010D FECB          DEC     BL
0BAC:010F EB14          JMP     0125
0BAC:0111 FEC3          INC     BL
0BAC:0113 89D8          MOV     AX,BX
0BAC:0115 B70A          MOV     BH,0A
0BAC:0117 F6F7          DIV     BH
0BAC:0119 88C3          MOV     BL,AL
0BAC:011B EB08          JMP     0125
0BAC:011D B309          MOV     BL,09
0BAC:011F 86C8          XCHG    CL,AL
0BAC:0121 D2EB          SHR     BL,CL
0BAC:0123 86C8          XCHG    CL,AL
0BAC:0125 E2DD          LOOP    0104
0BAC:0127 C3            RET
```
[Answer]
# [Perl 5](https://www.perl.org/) `-pF`, 36 bytes
```
$\+=$\?1-2*/-/:9-5*/-/,$\%=10for@F}{
```
[Try it online!](https://tio.run/##K0gtyjH9/18lRttWJcbeUNdIS19X38pS1xRE66jEqNoaGqTlFzm41Vb//6@trf0vv6AkMz@v@L9ugRsA "Perl 5 – Try It Online")
[Answer]
# x86-16 machine code, ~~27~~ 26 bytes
```
00000000: 33c0 803c 2d74 0a84 c075 02b0 0840 37eb  3..<-t...u...@7.
00000010: 0548 3f14 003f 46e2 e9c3                 .H?..?F...
```
**Listing:**
```
33 C0           XOR  AX, AX             ; clear accumulator 
            SLOOP: 
80 3C 2D        CMP  BYTE PTR[SI], '-'  ; is a "-"? 
74 0A           JZ   MINUS              ; is a minus operation 
84 C0           TEST AL, AL             ; is plus op and 0? 
75 02           JNZ  PLUS               ; if not, continue as plus op 
B0 08           MOV  AL, 8              ; otherwise add 8 
            PLUS:
40              INC  AX                 ; increment 
37              AAA                     ; if al > 9 { al = 0, cf = 1 } 
EB 06           JMP  DONE               ; done 
            MINUS: 
48              DEC  AX                 ; decrement 
3F              AAS                     ; if al < 0 { al = 9, cf = 1 } 
14 00           ADC  AL, 0              ; if cf { al = 10 }
3F              AAS                     ; if al == 10 { al = 4 } 
            DONE:
46              INC  SI                 ; next input instruction 
E2 E8           LOOP SLOOP
C3              RET                     ; return to caller
```
Callable function, input as string in `[SI]`, length in `CX`. Output to `AL`.
This is the first time I can ever think of where [`AAA`](https://www.felixcloutier.com/x86/aaa) and [`AAS`](https://www.felixcloutier.com/x86/aas) were actually useful in a challenge! These instructions, intended for BCD math, are able to be abused a little to do a bit of the dirty work here.
**Tests:**
[![enter image description here](https://i.stack.imgur.com/CFCpC.png)](https://i.stack.imgur.com/CFCpC.png)
[![enter image description here](https://i.stack.imgur.com/BvmPf.png)](https://i.stack.imgur.com/BvmPf.png)
[Answer]
# [Python 3](https://docs.python.org/3/), 92 bytes
```
f=lambda x,t=0:f(x[1:],{"+":{9:0,0:9},"-":{0:4}}[x[0]].get(t,t+eval(f"{x[0]}1")))if x else t
```
[Try it online!](https://tio.run/##K6gsycjPM/7/v8DWgCstv0ghWyEzD4gKSks0NK24FBQy0xSybW3VtdVBHDC3wNbWwKrA1hLMT82BiFhagQyAiBSnWhVo2xpyIas24YLJ6AJlCooy80o0CjT//9cFgv8A "Python 3 – Try It Online")
Expects input as a string of "-" and "+" as in the test cases.  
Recursively looks up the few exceptions or defaults to adding and subtracting one based on the first character of the given string.
[Answer]
# TI-Basic, ~~52~~ 47 bytes
```
Prompt A
For(I,1,dim(ʟA
If ʟA(I:Then
Ans+1+8not(Ans
Ans(Ans≤9
Else
Ans-1+5not(Ans
End
End
```
-5 bytes thanks to [MarcMush](https://codegolf.stackexchange.com/users/98541/marcmush).
Takes input as a list of 0s and 1s. Output is stored in `Ans` as an integer. Note that there can not be empty lists in TI-Basic, so the first test case throws an error. The below version has 8 bytes more but outputs 0 for the first test case.
---
### ~~60~~ 55 bytes
```
Prompt Str1
For(I,1,length(Str1
If expr(sub(Str1,I,1:Then
Ans+1+8not(Ans
Ans(Ans≤9
Else
Ans-1+5not(Ans
End
End
```
Takes input as a string of "0"s and "1"s. Output is stored in `Ans` as an integer.
[Answer]
# [Brain-Flak](https://github.com/Flakheads/BrainHack), 132 bytes
```
([](<()>)){({}[()]<((){[()](<(({}({})[()]{})[(()()()()()){}])((){[()](<{}>)}{}){((<{}{}>))}{}>)}{}){(<{}(((({})()){}){}{})>)}{}>)}{}
```
[Try it online!](https://tio.run/##RYwxCoAwDEWv8/9W99KLlA7VRREcuoacPSaKlgSS/3jJOvpx7X07zVAbMlhIgWgFWwYosTh35M1IzwC/omjjNEUL1RVB7JGokzkC4tl7yDBYfsPMFkuWbg "Brain-Flak (BrainHack) – Try It Online")
This loses a lot of bytes to simple equality checks (equals 0 and equals 10).
[Answer]
# [Python 3](https://docs.python.org/3/), ~~151~~ 117 bytes
```
p=0
for k in input():
  if k=='+':
    if p==0:p=9
    elif p==9:p=0
    else:p+=1
  if p==0:p=4
  else:p-=1
print(p)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/v8DWgCstv0ghWyEzD4gKSks0NK24FBQy0xSybW3VtdVBHDC3wNbWwKrA1hLMT82BiFhagQyAiBSnWhVo2xpyIas24YLJ6AJlCooy80o0CjT//9cFgv8A "Python 3 – Try It Online")
@pxeger So Nice thank you -35 bytes
[Answer]
## [CESIL](http://www.obelisk.me.uk/cesil/) , 850 bytes (including data section)
CESIL was taught in UK schools until the mid-1980s (I may have been in one of the last years that had it as an introduction before moving on to the powerhouse of BASIC).
This has been run through a parser I wrote in Python as a little exercise, each column is tab separated.
Everything has to be moved in and out of the accumulator for any function to be performed on that.
There was no real input, as it was designed for punched cards, so data has to be in a separate section at the end (I use -1 and 1 to indicate both temperature controls, and zero to terminate). It gave the correct results from the samples, but did mean I had to update the data section each time, save it, and run it again.
```
        LOAD    0
        STORE   HEAT
LOOP    IN
        JIZERO  END
        STORE   BUTTON
        ADD     HEAT
        STORE   TMP
* CHECK ZERO DOWN TO 4
        JINEG   ZTF
* CHECK 9 UP TO 0
        LOAD    TMP
        SUBTRACT        10
        JIZERO  NTZ
* CHECK 0 UP TO 9
        LOAD    BUTTON
        JINEG   DEC
        LOAD    TMP
        SUBTRACT        1
        JIZERO  ZTN
        LOAD    TMP
        STORE   HEAT
SHOW    LOAD    HEAT
        PRINT   "HEAT IS "
        OUT
        LINE
        JUMP    LOOP
DEC     LOAD    TMP
        STORE   HEAT
        JUMP    SHOW
END     HALT
* 0 GOES DOWN TO 4
ZTF     LOAD    4
        STORE   HEAT
        JUMP    SHOW
* 9 GOES UP TO 0
NTZ     LOAD    0
        STORE   HEAT
        JUMP    SHOW
* ZERO GOES UP TO 9
ZTN     LOAD    9
        STORE   HEAT
        JUMP    SHOW
        %
        -1
        -1
        -1
        1
        0
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 23 bytes
```
 m?Z=Z%?dhZtZT=Z?d9 4QZ
```
[Try it online!](https://tio.run/##K6gsyfj/XyHXPso2StU@JSOqJCrENso@xVLBJDDq//9oAx0FCDKMBQA "Pyth – Try It Online")
```
 m?Z=Z%?dhZtZT=Z?d9 4QZ   Q auto-initialized to input; Z auto-initialized to zero
 m                   Q    Map through input, using 'd' as current element
  ?Z                      If Z is not 0:   
    =Z%?dhZtZT                          Z++ or Z--, Then modulo by 10
                          Else:
              =Z?d9 4          Z = 9 if + or 4 if -
                     Z    Print Z   
```
[Answer]
# Python 3, 86 bytes
```
def f(c,t=0):
 if len(c):p=c[0];t=((0,9,4)[p],t+p)[t>0]%10;return f(c[1:],t)
 return t
```
Takes input as a list of 1s and -1s, 1 indicating a + button press and -1 indicating a - button press.
[Try it online!](https://tio.run/##bVHBqsIwELznK5bCgyymkKIXK/XyfuHdYhCpCQY0hnR7eF9fU6tYo3vJ7szO7LIJ/3S6@uUwHI0Fy1tBjcSagbNwNp63WIemVVJvqOFcirVYoQpa0CKgoq3UP5XcREN99KNaVXXikMEDooFMR3vnQ08dNKAYpFBaTG9ZPbPqBQko36pXz5yZE5Mm15V5y6dzbp4NyKd/LPB1h297TE5MM3uNwJ2A8SwIzoPx/cXEAxk@u9T4ASlCdJ548ZcI@D10BgpYQEeRO0xJUe/8jp6QvesRcbgB "Python 3 – Try It Online")
Recursively handles the exceptions that happen in what might be considered the expected function of the buttons, each at t==0.
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 68 bytes
Nice little lookup table solution.
Thanks to Jay Ryan for -7 bytes, and for making me revisit my code to find and fix a bug! 8 definitely is not 0, much to my previous solutions disbelief.
```
lambda s,a=0:[[a:=b'49021324354657687980'[c+2*a]-48for c in s],a][1]
```
[Try it online!](https://tio.run/##NZDLjsMgDEX3fAU7whiqvB9IfAnNgnYUTaQ2RcAi/XoGp@nG19c@WFe4d/x7bc3ofFr0NT3s8/ZraRBWl8oYq/SNtVNZV03dNl3bd0M/DtNYMnOH@sfOsh2Xl6d3um40zMLOppoTidrsl@AeayyYYpwisiPCGKOKlkTm2hLIdSISTUMkuo4AupEAfLhjWWeF44UEeSr6PtPoh6yfW3DuAb63D6DCBidNDvANdt0YnwnBbEF4TBcVoc6vWyyCWIqndcX5HbvatWbARLiE6FdXcM6F5yn9Aw "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~14~~ 13 bytes
```
¹o8 5<?+%⁵µƒ0
```
[Try it online!](https://tio.run/##y0rNyan8///QznwLBVMbe23VR41bD209Nsng/8PdW2wfNczV1dU63P6oaU3k//9culzaXLq6XLraXNpAJogN5AB5utogQZAoUBgkC5YGy4MU6GoDAA "Jelly – Try It Online")
-1 thanks to xigoi: -1 is always smaller than the accumulator, and the right argument to `o` doesn't matter if it's nonzero anyways
Takes input as 1/-1.
```
           ƒ     Reduce from
            0    zero
          µ      :
¹                (break the leading triple dyad pattern.)
 o               Logical OR the left argument with
  8              eight
     <?          if it is less than the right argument,
    5            else five.
       +         Add the right argument to the result,
        %⁵       mod 10.
```
[Answer]
# [Julia](http://julialang.org/), 47 bytes
```
l->(n=0;[n=n>0 ? (n+2i-1)%10 : 4+5i for i=l];n)
```
[Try it online!](https://tio.run/##VU9BjsIwDLz7FVakFY1MpAa2yy4ocOYNpYcVS6WgyItokPh9sQMcmkOcGU/G4/MtxV9/H/swJretONSblgNva9xhxbSIztsPX@MaP6mJ2P9fMYbUbdiO@TTkAQMaY0D6NThVAcn9A07BEpyiBkjRNxA9daW5kErlhyP3qoq/RK14JfXpRa8@0du7CLw@qIzRCAAaTkNhZBwuKeaqRJybAxvb@vWJ/5zvAOVcrpFz4iKwhUmyyZ5zewxhRrOy6HFqNDcyS426qUeyE9gLMWUsyOTxAQ "Julia 1.0 – Try It Online")
[Answer]
# [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), 111 bytes
```
	X =0
N	I =INPUT	:F(O)S($I)
A	X =REMDR(X + 1,10)
	X =EQ(X,1) 9	:(N)
S	X =X - 1
	X =4	LT(X)	:(N)
O	OUTPUT =X
END
```
[Try it online!](https://tio.run/##K87LT8rPMfn/nzNCwdaAy4/TU8HW0y8gNITTyk3DXzNYQ8VTk8sRJBnk6usSpBGhoK1gqGNooMkFEnMN1IjQMdRUsOS00vDT5AoGiUUo6CoYgmVNOH1CNCI0IXL@nP6hIUBzgQq4XP1c/v93BAA "SNOBOL4 (CSNOBOL4) – Try It Online")
Uses `A` for `+` and `S` for `-`, separated by newlines.
```
	X =0				;* Set X
N	I =INPUT	:F(O)S($I)	;* read input. If empty, goto O, else goto label identified by I
A	X =REMDR(X + 1,10)		;* Incremenet X, mod 10
	X =EQ(X,1) 9	:(N)		;* if X = 1, set it to 9. Goto N
S	X =X - 1			;* decrement X.
	X =4	LT(X)	:(N)		;* If X is less than 0, set X to 4. Goto N.
O	OUTPUT =X			;* Output X and exit.
END
```
SNOBOL won't reassign values on a FAILURE, so `X =EQ(X,1) 9` is a no-op if X isn't equal to 1.
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 30 bytes
```
0l1=?n:?v~49{?$~!
+1-a%00.>{2*
```
[Try it online!](https://tio.run/##S8sszvj/3yDH0NY@z8q@rM7EstpepU6RS9tQN1HVwEDPrtpI6////7plCgYA "><> – Try It Online") (or [fishlanguage.com](https://fishlanguage.com/), as this input format is a bit tricky)
Takes an array of `0`s(decrement) and `1`s(increment)
```
---row 1---
0               !    Initialisation
 l1=?n:              Termination
       ?             Branching to special case 0
         ~49{?$~       0 branch, discard 4 or 9 depending on button
---row 2---
+1-a%   >{2*           other branch, conditional increment/decrement mod 10
     00.               loop
```
[Answer]
# [Befunge-98](https://esolangs.org/wiki/Funge-98), 21 bytes
```
:&|@>#.
-1_4^
+1_9^%a
```
[Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz//@3UqtxsFPW49I1jDeJ49I2jLeMU038/z/aUEcBggzAyDAWAA "Befunge-98 (PyFunge) – Try It Online")
Input as a list of `0`s and `1`s (or any other format with some character after the last number).
## Explanation
```
:&|@>#.
:        Create a copy of the temperature counter (which starts at 0).
 &       Get the next input number.
  |      Is it 0 (minus) or 1 (plus)?
         If the input is 0, move down to the second line.
         If the input is nonzero, move up (and wrap around) to the third line.
    >    Once the program has returned to the first line:
     #   Skip the next instruction.
      .  (skipped)
         Repeat.
On EOF:
:        Duplicate the final temperature.
      .  Print it.
     #   Skip the next instruction.
    >    (skipped)
   @     End the program.
    
  
Second line (minus):
-1_4^
  _      Is the copy of the current temperature zero?
         If so, 
   4            replace it with 4, 
    ^                              and return to the first line.
         If not, 
-                subtract 
 1                        1, 
    ^                        and return to the first line.
Third line (plus):
+1_9^%a
  _      Is the copy of the current temperature zero?
         If so, 
   9            replace it with 9, 
    ^                              and return to the first line.
         Otherwise, 
+                   add 
 1                      1, 
     %   take the result modulo 
      a                         10, 
    ^                               and return to the first line. 
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell) 7, 50 44 bytes
```
$args|%{$x=$_ ?$x ?++$x%10:9:$x ?$x-1:4};+$x
```
TIO still runs on PS 6, which this solution is incompatible with, so no Try It Online link, for now.
# Explanation
```
$args|%{                            #For each number in the argument list (0 or 1)
    $x=                             #Assign to x
        $_                            #Ternary on the number
            ?                           #Number is non-zero, + button was pressed
                $x                        #Ternary on x
                    ? ++$x%10               #x is non-zero, set x to its increment mod 10
                    : 9                     #x is 0, set x to 9
            :                           #Number is zero, - button was pressed
                $x                        #Ternary on x
                    ? $x-1                  #x is non-zero, decrement
                    : 4                     #x is zero, set x to 4
}                                   #End for each loop
+$x                                 #Output x, coercing it to 0 if null
```
]