text:
Expand the number
You may remember in first or second grade using expanded form to learn about place value of numbers. It's easier to explain with an example, so consider the number 123. In expanded form it is represented as 100 + 20 + 3, which helps a young mind visualize place value. It is reminiscent of how you say it: one hundred (plus) twenty (plus) three.
We can extend this past the units place with decimals: 2.718 => 2 + 0.7 + 0.01 + 0.008
Your challenge is to write a program or function that takes a positive floating point number or zero (assume it is as large or precise as your language can handle; it will not be in scientific notation) or string and prints/returns it in expanded form as explained above.
You need neither spaces between the +'s nor the zero before the decimal point, so the example above could be 2+.7+.01+.008. Values that would be equal to zero must be omitted (101.01 => 100 + 1 + 0.01) unless the input is zero (see below).
Values should not have more than one leading zero before the decimal point or any trailing zeroes after it (no-no's: 0060, 0000.2, 30., 30.000, .0400). The input will conform to this too.
Since first-graders have short attention spans, your code will have to be as short as possible.
Test cases
0 => 0
6 => 6
0.99 => 0.9 + 0.09
24601 => 20000 + 4000 + 600 + 1
6.283 => 6 + 0.2 + 0.08 + 0.003
9000000.0000009 => 9000000 + 0.0000009

+1 for "Since first-graders have short attention spans, your code will have to be as short as possible."

Can the input be string?

@ChristianIrwan Yes, it says so above, but I guess it's confusingly worded

@Doᴡɴɢᴏᴀᴛ glad to see the meme is still running.

It would have be funny to do it in the same way we (french) count, to see people strugle with  the case of 97(4*20+10+7) ^^

CJam outputs 0.000009 as 0.000009 but 0.0000009 as 9e-7, and arguably it's too precise for CJam. Is that allowed?

@jimmy23013 Yes, as long as it works in theory.

Could the input have trailing zeros? E.g. 15.20 or 1.0.

@randomra No, the input will conform to the same restrictions as the output.

@Katenkyo That would be horrible/hilarious! Perhaps it could be the seed of another puzzle?

@NBZ How does that give 197?

@Ogaday I don't know, it's only some edge cases. Maybe NBZ way would be better, but still, don't if it would really be interesting

@Thrax Edit typo: Much worse in Danish: 197 = 100 + 7 + ((5 + 4) / 2) × 20.

CJam, 33 26 bytes
r_ee\'0fe<f{\~t~}{},'+*0e|

This won't work with the Java interpreter; it print floats differently. Try it with the CJam interpreter.
The last test case prints 9000000+9e-7, which has been ruled valid by @NinjaBearMonkey.
Thanks to @jimmy23013 for golfing off 7 bytes!
How it works
r_                           Read a token from STDIN and push a copy.
  ee                         Enumerate its characters, i.e., push the array of all
                             [index character] pairs.
    \                        Swap the original input on top of the stack.
     '0fe<                   Perform vectorized minimum with the character '0'.
                             This replaces all digits with '0', but leaves '.'
                             untouched, since `.' < '0'.
          f{    }            For each [index character] pair, push the pair and the
                             string of zeroes and (possibly) a dot; then:
            \                    Swap the pair on top of the stack.
             ~                   Dump index and character on the stack.
              t                  Replace the string's element at that index with
                                 that character.
               ~                 Evaluate the resulting string.
                 {},         Filter the array to remove zeroes.
                    '+*      Join, using '+' as separator.
                       0e|   If the result is empty, replace it with 0.

Based on the same idea: r_ee\'0fe<f{\~t~}{},'+*0e|.

@jimmy23013 Wow, that is short! Thank you!

JavaScript (ES7), 102 bytes
n=>+n&&[...n.replace(/^\.0*|\./,"")].map(f=d=>10**p--*d,p=Math.floor(Math.log10(n))).filter(f).join`+`

Explanation
Requires the number to be input as a string without leading zeroes (unless the number is 0 of course).
Note: Because of floating-point weirdness some numbers (like .3) come out wrong, but theoretically this works for any number.
n=>                             // n = input number as string
  +n&&                          // return 0 if n = 0
  [...n.replace(/^\.0*|\./,"")] // remove leading zeroes after the decimal place
  .map(f=d=>                    // for each digit d in n
      10**p--*d,                // raise the digit to the correct power of 10
    p=Math.floor(Math.log10(n)) // p = power of 10 for the first digit, floor needs to be
  )                             //     used instead of |0 due to negative powers of 10 :(
  .filter(f)                    // remove zeroes, the map function is reused
  .join`+`                      // return the output numbers joined with +

Test
Test uses Math.pow instead of ** for browser compatibility.

var solution = n=>+n&&[...n.replace(/^\.0*|\./,"")].map(f=d=>Math.pow(10,p--)*d,p=Math.floor(Math.log10(n))).filter(f).join`+`
<input type="number" oninput="result.textContent=solution(this.value)">

Math.floor => 0|...?

@ETHproductions If the input number is less than 1 it would break because Math.log10(n) would return a negative number and |0 rounds towards zero instead of flooring.

Can you use 0|Math.log10(n),p-=p<0 instead of Math.floor(Math.log10(n))?

@DomHastings Almost. It fails for n<1 because the 0| will make p equal 0 for both 0.1 and -0.1. The shortest way I can think of is p=Math.log10(n),p=p-(p<0)|0 which is the same length as using Math.floor. :(

@DomHastings Still wouldn't work for n=0.1 anyway.

Test doesn't work for following:
.3 -> 0.30000000000000004,
.6 -> 0.6000000000000001,
.7 -> 0.7000000000000001,
and more importantly:
0.1 -> 0.01,
0.01 -> 0.0001, etc. All zeroes get doubled.
So pretty much solution is broken. Solution is not about "someone's fault", but about "it works". DNQ.

@metalim In regards to your first tests, floating-point numbers cannot represent every real number. That's just how they work. The question asks for a floating-point number, so I'd assume your first examples are allowed. For the others, as I state in the description: "Requires the number to be input as a string without leading zeroes". This is explicitly allowed by the question with "You need neither spaces between the +'s nor the zero before the decimal point" and the OP's comment "the input will conform to the same restrictions as the output".

@user81655 Comment "the input will conform to" refers to invalid inputs - there are no 006 or 0.100 inputs allowed. Program should work for all valid inputs. As for floating point number representation: text representation is strict and easy: 0.3 does not equal 0.300000whatever. Task of a developer is to make a program that conforms to the requirements, not to explain the quirks of implementation instead.

Retina, 86 77 75 bytes
Byte count assumes that the source is encoded as ISO 8859-1.
S_`.(?<=(\.\d+))|(?=(\d*)).
Tm`d`0`\..+\B|(?<=^\d).+
¶([.0]+¶)*
+
^0.|\+0$

The trailing linefeed is significant.
Try it online.
Explanation
S_`.(?<=(\.\d+))|(?=(\d*)).

We start by turning the input into a linefeed separate list of components, although only the leading (or trailing) digit is correct. This is done by abusing a split stage. Instead of splitting the input we match all of it, so the remaining segments are all empty. We remove those empty segments with the _ option. The catch is that split stages also return the values of all capturing groups. So we use a lookahead at each match to capture the correct part of the string: first we try to find a . left of the match. If that's the case, we capture everything from the . up to and including the digit we're currently matching. Otherwise, we must be in the integer part of the input, so we capture all the numbers after the match (including the match). We must also get rid of the decimal point itself, so the second capture is optional. If there are no \d to be capture, this will simply remove the match from the input.
Tm`d`0`\..+\B|(?<!=\d).+

Now we use a transliteration stage to turn all but the leading/trailing digits into zeroes. We either match a component that's less than 1 with \..+\B where the \B ensures that we stop the match one digit before the end, or we match an integer part with (?<=^\d).+ where the lookbehind ensures that we start one digit into the number. The transliteration stage will then replace any digits (d) with zeroes inside the matches.
¶([.0]+¶)*
+

Now the actual output format should use + not linefeeds as separators. The ¶ matches a linefeed to do that substitution. While we're at it, we also remove lines that contain only 0s and .s.
^0.|\+0$

The previous stage does not remove a leading or trailing 0 (because those do not have a linefeed before and after them), so we remove those explicitly.

Python 2, 216 210 196 175 bytes
Here is some slightly golfed code that I will golf further when I get time. It uses string analysis.
i=input().split(".")
I=i[0]
e=enumerate
o=[(k+len(I[j+1::])*"0") for j,k in e(I) if k!="0"]
try:o+=["."+l*"0"+m for l,m in e(i[1]) if m!="0"]
except:0
print "+".join(o or"0")

Explanation
So, the input is seperated into a integer and decimal part. Then, there is a for loop list comprehension. On the integer part, the length of the string after a character in the decimal is multiplied by "0" to get that many zeros at the end if that character.
For the decimal part, the index of the current character is the number of zeros before it and so that part is simple.
The try and except is used to determine whether it has a decimal part or not (using an error).
The final result is joined with plus signs.
Try it here!

I think o if o else ["0"] can be o or["0"].

You have a trailing space on line four which adds to your byte count. On line four you only need one colon. You can delete the spaces in the following snippets: o=[(...)] for,e(I) if,e(i[1]) if,print "+", and the outer parenthesis in o=[(...) as well, actually. Finally, you can take the final conditional out of the join function like this: print"+".join(o)or"0" because join will return an empty list if o is empty so the conditional will evaluate the same way which saves you one byte.

Pyth, 30 bytes
L.xvbytb|j\+fT.eyXXzjkUT\0kbzz

Test suite
The basic solution here is to replace all of the digits in the input with 0, then insert each digit at the proper location, eval, filter out the zeros, and join on pluses. Unfortunately, Pyth's eval function doesn't accept leading zeros currently. I will be working to fix this.
To get past this problem, I added a helper function, y, which recursively retries the eval until no error is thrown, removing the first digit every time. Note that this function will loop infinitely on invalid input.
Also, a special case was needed for the input 0.
All in all, I think the code's pretty good, but the language facilities could be better. Who wants errors?

Python 3, 138
This is loosely based on TanMath/Ogaday's approach of reading the number as a string and parsing it out that way. I have to use star assignment on i so that it correctly handles integers.
j,*i=input().split(".")
e=enumerate
z="0"
print("+".join([(x+len(j[y+1:])*z)for y,x in e(j)if x>z]+["."+o*z+p for o,p in e(i)if p>z]or z))

Python, 141 132 128 bytes
This one is still relatively readable. Convert to string and handle the >1 digits separately from the <1 digits. We also have a special case for zero. I could remove two more spaces below, but I like keeping it pretty.
The downside is that it will breakdown for floats with more than 9 decimal places.
x=str(int(a*1e9))
l=len(x)-10
z="0"
print"+".join([(j+z*(l-i))if l>=i
 else"."+z*(i-l-1)+j
 for i,j in enumerate(x)if j!=z]or z)

Below is the original. First edit was to shorten the zero special case, second edit was to remove the 0 before the decimal, third was to remove some extra parenthesis and spaces.
x=str(int(a*1e9))
l=len(x)-10
z="0"
print "+".join([(j+z*(l-i)) if l>=i
 else ("0."+z*(i-l-1)+j)
 for i,j in enumerate(x) if j!=z]) if a else z

Explanation:
x=str(int(a*1e9)) # Convert into a string with nine decimals
l=len(x)-10
z="0"
print "+".join([
 (j+z*(l-i)) if l>=i       # Print numbers greater than 1
 else ("0."+z*(i-l-1)+j)   # Print less than one
 for i,j in enumerate(x) if j!=z
]) if a else z             # Special case zero

You don't need to include every revision of your code; if we want to see your golfing progress we can look at the revision history. By the way, welcome to PPCG!

Just discovered it... I'm going to have to try not to spend too much time on this site!

Mathematica, 81 bytes
Inactive@Plus@@(10.^Range[#2-1,#2-Length@#,-1]#/.{0.->Nothing[]})&@@RealDigits@#&

Test case:
%[101.01]
(* 100. + 1. + 0.01 *)

I don't think having the decimal point over the integer parts is allowed.

CJam, 44 bytes
r:TdLT'.-{'0f+IaaI~g*+}fI:dATW%'.##m]f/'+*e&

Try it here.
It fails the last test case, and outputs the following:
9000000+9e-7

But let's say it's too precise that CJam cannot handle it.
Explanation
r:Td
LT'.-         e# Remove the period if any.
{             e# For each character I:
  '0f+        e# Append 0 to each previous string.
  IaaI~g*+    e# Append I as a string if I isn't '0.
}fI
:d            e# Convert each string to float.
ATW%'.##      e# 10 to the kth power where k is the position of the period from the end.
m]            e# Round up, so it becomes 1 if no periods are found.
f/            e# Divide each float by this number.
'+*e&         e# Format and the 0 special case.

Python 3, 187 180 173 154 bytes
Managed to golf a good 19 bytes off thanks to @Thomas Kwa's suggestions above about result or['0'], plus rearranging some algebra (154 bytes):
def f(n):
 *m,=n;o='0'
 try:p=m.index('.');m.pop(p)
 except:p=len(m)
 return'+'.join([['.'+o*(i-p)+d,d+o*(p-i-1)][p>i]for i,d in enumerate(m)if d!=o])or o

My best attempt so far (173 bytes). Based upon new approach, see bottom of post:
def f(n):
 *m,=n;o='0'
 try:p=m.index('.');m.pop(p)
 except:p=len(m)
 return(o,'+'.join([['.'+o*(-1*(p-i))+d,d+o*(p-i-1)][p-i>0]for i,d in enumerate(m)if d!=o]))[eval(n)!=0]

golfed my original down to 180 bytes:
def f(n):x=n.split('.');a,b=(x+[''],x)[len(x)-1];e=enumerate;return('0',"+".join([d+'0'*i for i,d in e(a[::-1])if d!='0'][::-1]+['.'+'0'*i+d for i,d in e(b)if d!='0']))[eval(n)!=0]

I learnt a new language feature today doing this! Conditionals via boolean indexing. I may have slightly overdone it.
I tried abstracting out the comprehensions, but I couldn't make it any shorter (196 bytes):
e=lambda s:[d+'0'*(len(s)-i-1) for i,d in enumerate(s) if eval(d)]
def f(n):x=n.split('.');a,b=(x+[''],x)[len(x)-1];return['0',"+".join(e(a)+['.'+d[::-1]for d in e(b[::-1])][::-1])][bool(eval(n))]

(Reversing sequences is expensive!)
Whilst mine is shorter for now, I think TanMath can golf his down to match mine: Using e=enumerate, replacing pass with 0, and using '0' in place of ['0'] in the return statement should save 4+3+2=9 bytes! Taking it down to 187. I'm sure another few bytes can be shaved off somewhere...
edit New approach (156 bytes). However, it can only deal with precision up to 6dp similar to @jimmy23013's CJam entry, so it fails the final test. I couldn't coerce it to print more 0s, maybe someone else can. Instead I used it as the basis of my best attempt yet, see top (Also, this approach prints the 0 before the decimal place, but that seems valid as well.). Took the try:... except:... approach from TanMath:
def f(n):
 *m,=n
 try:p=m.index('.');m.pop(p)
 except:p=len(m)
 return('0','+'.join([str(eval(d)*10**(p-i-1))for i,d in enumerate(m)if d!='0']))[eval(n)!=0]

If you are trying to give golfing help to me, please include them as comments to my answer, not in your answer. I do not always see your answers, so by writing a comment, I will get a notification and definitely see it.

Hi @TanMath. I would, but I don't have enough rep to comment on other people's posts yet. Once I get a few more upboats I'll make sure to leave feedback in comments.

Dyalog APL, 47 bytes
{×⍎⍵:1↓∊'+',¨0~⍨(⍎¨w)×10*(⍵⍳'.')-1+⍳≢w←⍵~'.'⋄0}

Takes number in character vector form, e.g. '123'.
Examples:
      f←{×⍎⍵:1↓∊'+',¨0~⍨(⍎¨w)×10*(⍵⍳'.')-1+⍳≢w←⍵~'.'⋄0}
      ↑⍕¨f¨,¨'0' '6' '0.99' '24601' '6.283' '900000.000009'
0
6
0.9 + 0.09
20000 + 4000 + 600 + 1
6 + 0.2 + 0.08 + 0.003
900000 + 0.000009

Notes:
○ The reason for the modified last example is that APL, like some of the other submissions, by default will switch to scientific notation for such extreme numbers.
○ The phrase ↑⍕¨f¨,¨ is only needed to process all examples at once.

Python, 131 bytes
f=lambda s,k=0,i=0,o="",z="0":s and f(s[1:],(s<z)+k,i+k,o+(s>="1")*([s[0]+~-(s+".").find(".")*z,"."+z*i+s[0]][k]+"+"))or o[:-1]or z

A really, really messy recursive function, probably not the best way to go about this. Input like f("10.0203").

Is this even Python? Love it.

pure bash, 210
o= a=${1%.*} b=${1#$a};while [ "$a" ];do c=${a:1};((${a%$c}>0))&&o+=${a%$c}${c//?/0}+;a=$c;done;[ "$b" ]&&{ b=${b#.} a=;while [ "$b" ];do c=${b:0:1};((c>0))&&o+=.$a$c+;b=${b:1};a+=0;done;};o=${o%+};echo ${o:-0}

or
o= a=${1%.*} b=${1#$a};while [ "$a" ];do c=${a:1};((${a%$c}>0))&&
o+=${a%$c}${c//?/0}+;a=$c;done;[ "$b" ]&&{ b=${b#.} a=;while [ "$b" ]
do c=${b:0:1};((c>0))&&o+=.$a$c+;b=${b:1};a+=0;done;};o=${o%+};echo ${o:-0}

Test:
exp() {
    o= a=${1%.*} b=${1#$a};while [ "$a" ];do c=${a:1};((${a%$c}>0))&&
    o+=${a%$c}${c//?/0}+;a=$c;done;[ "$b" ]&&{ b=${b#.} a=;while [ "$b" ]
    do c=${b:0:1};((c>0))&&o+=.$a$c+;b=${b:1};a+=0;done;};o=${o%+};echo ${o:-0}
}
while read num;do
    printf "%-12s => " $num
    exp $num
done <<<$'0\n6\n0.99\n24601\n6.283\n9000000.0000009\n3.1415\n.99'
0            => 0
6            => 6
0.99         => .9+.09
24601        => 20000+4000+600+1
6.283        => 6+.2+.08+.003
9000000.0000009 => 9000000+.0000009
3.1415       => 3+.1+.04+.001+.0005
.99          => .9+.09

C, 155 153 161 bytes
+2 to link in the math library (source itself is 159).
main(d,v,p,q)char**v,*p,*q;{for(p=strchr(q=v[1],46),d=p?p-q:strlen(q);*q;++q)*q^46?printf(*q^48|q==v[1]?"%.*f%c":"",d<0?-d:0,(*q-48)*pow(10,--d),q[1]?43:0):0;}

Ungolfed
int main(int d, char **v, char *p, char *q)
{
    for(q = v[1], /* Cache the input string */
        p = strchr(q,'.'), /* find the decimal */
        d = p ? p-q : strlen(q); /* calculate number of digits before decimal */
        *q; /* loop while still input data */
        ++q) /* iterate to next character */
    {
        *q^46 /* if not at the decimal point... */
            ? printf(*q^48 || q == v[1] /* if not a zero, or if the string itself is zero... */
                ? "%.f%c" /* print the digit */
                : "", /* else print nothing */
                d<0 ? -d : 0, /* Calculate number of places after decimal to print */
                (*q-48)*pow(10,--d), /* Calculate the digit at the desired power of 10 */
                q[1]?43:0) /* If the next character is still valid input, print the '+' */
            : 0 /* else, do nothing */
    }
}

Java, 284 244 243 Bytes
String x(String s){int b=s.length(),d=(d=s.indexOf(46))<0?b:d,i=-1,k=0;String o="";for(char c;++i48?(k++>0?" + ":"")+(d-i>0?c:"0.")+new String(new char[Math.abs(d-i)-1]).replace('\0','0')+(d-i>0?"":c):"";return b<2?s:o;}

Unfortunately, I could not find a shorter way of creating repeating Strings than:

build a char[] of the required length
use Arrays.fill to set the characters
use new String so it can be concatenated

With inspiration by @Khaled A Khunaifer, I could shave off 40 Bytes.
Edit: indexOf takes an int, so I could replace '.' with 46.
Unfortunately, this does not seem to be possible with replace.

I managed to shrink it down to 250, check http://ideone.com/HqLnMo

@Khaled A Khunaifer Your solution seems to have problems with single digit test cases. But I like your way of generating the zeros.

fix this .replace('\0','0') function replace expect String not char, it should be .replace("\0","0")

@Khaled A Khunaifer It works in my test cases, also https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#replace-char-char-

Retina, 113 bytes
Currently much longer than Martin's solution but uses a different method so I decided to post it.
^
x
S_`(?<=(.*)).(?=(.*))
x

¶\..*¶.*

$
¶
T`d`0`(?<=\d).*¶.*¶
(.*)¶(.*)¶
$2$1¶
(\..*?)0*¶
$1¶
\.?¶0*
¶
¶+
+
\+$
[empty line]

Try it online here.

Perl, 248 bytes
Ew, I am noobish at Perl golfing.
@a=split/\./,<>;
@b=split``,$a[1];
@c=split``,$a[0];
for($i=0;$i<length$a[0];$i++){
   $_.=($c[$i]!=0)?$c[$i]."0"x((length$a[0])-$i-2)."+":"";
}
for($i=1;$i<=length$a[1];$i++){
   $_.=($b[$i-1]!=0)?"0."."0"x($i-1).$b[$i-1]."+":"";
}
chop;
($_=="")?print"0 ":print;

Try it here.

This seem not work with integer numbers.

I put the wrong Ideone link. It doesn't take into account changes made in Edit mode. :( It should work now.

You have an error somewhere: when I enter 5 it return 50.

Strange, since I tested 5 with the link I provided yesterday after you put your first comment. Mind trying now ? (I changed the link again)

I just tested your script on my perl interpreter (v5.20.2)

Ah, figured it out : it's because Ideone ignores the trailing newline when something is in stdin, while executing the script inside the interpreter adds a trailing newline at the end of the input, adding 1 to the length of the array. Meh :c

36 => 300+60! I've copied your script to a script file, added shebang #!/usr/bin/perl and run by: ./exp.pl <<<36;echo ... (work fine with floating:  3.62.=> 3+0.6+0.02)

Changed a bit : ((length$a[0])-$i-2) instead of ((length$a[0])-$i-1) in the first loop. Should be ok now. (I could chomp the input, but it adds a lot more characters)

Well now, this seem correct! +1 for debugging effort!

perl, 132 bytes
131 +1 for -p switch.
This is based on my previous sed answer:
1while s/^([1-9]\d*)([1-9])(0*)([+.].*|)$/${1}0$3+$2$3$4/||s/([1-9]0*)\.([0-9])/$1+.$2/||s/\.(0*)([1-9])(\d*[1-9])$/.$1$2+.${1}0$3/

Test suite:
perl -pe'1while s/^([1-9]\d*)([1-9])(0*)([+.].*|)$/${1}0$3+$2$3$4/||
    s/([1-9]0*)\.([0-9])/$1+.$2/||s/\.(0*)([1-9])(\d*[1-9])$/.$1$2+.${1}0$3/
' <<<$'0\n6\n0.99\n24601\n6.283\n9000000.0000009\n3.1415'
0
6
0.9+.09
20000+4000+600+1
6+.2+.08+.003
9000000+.0000009
3+.1+.04+.001+.0005

Powershell - 172 166 193 bytes
All on a single line:
$z=([string]$args[0])-split"\.";$y=$z[0].length-1+0.6;($z|%{$x=[char[]]$_;if($y-gt0){($x|%{$_+"0"*(-1+$y--)})}else{($x|%{"0."+"0"*[math]::abs($y--)+$_})}}|?{-not($_-match'^[0.]+$')})-join' + '

Ungolfed:
$z=([string]$args[0]) -split "\."
$y=$z[0].length-1+0.6
($z | %{
    $x=[char[]]$_
    if($y -gt 0) {
        ($x | %{$_+"0"*(-1+$y--)})
    } else {
        ($x | %{"0."+"0"*[math]::abs($y--)+$_})
    }
} | ?{ -not($_ -match '^[0.]+$')}) -join ' + '

Test cases, plus one additional:
PS> (0, 6, 0.99, 24601, 6.283, 9000000.0000009, [math]::pi) | %{.\expand.ps1 $_}

6
0.9 + 0.09
20000 + 4000 + 600 + 1
6 + 0.2 + 0.08 + 0.003
9000000 + 0.0000009
3 + 0.1 + 0.04 + 0.001 + 0.0005 + 0.00009 + 0.000002 + 0.0000006 + 0.00000005 + 0.000000003 + 0.0000000005 + 0.00 000000008 + 0.000000000009 + 0.0000000000007 + 0.00000000000009
PS>

Your regex filters out $args = 0. Here's a simple bug fix that also saves 3 bytes

172 bytes after a slight revamp

CoffeeScript, 144 bytes
Straight forward solution:

X=(n)->[m,k]="#{n}".split '.';(c+Array(m.length-i).join 0for i,c of m when+c).concat(".#{Array(++i).join 0}"+c for i,c of k when+c).join('+')||0

Executable:

<input type="number" oninput="result.textContent=solution(this.value)">

Python, 125 bytes
After deleting my 1st answer (sry!) which could not handle small numbers due to machine epsilon issues, I found a different solution. It handles float as well as integers, trailing zeros (!) and is written as function.
Thanks to @ogaday for the useful hints and for the compact '0'-fix!
Golfed:
def f(x):x+='.';i=x.find('.');z=list(x);del z[i];return'+'.join([str(int(o)*10**(i-j-1))for j,o in enumerate(z)if'0'<o])or'0'

Ungolfed:
def f(x):
  x+='.'
  i=x.find('.')
  z=list(x)
  del z[i]
  return '+'.join([str(int(o)*10**(i-j-1)) for j,o in enumerate(z) if '0'<o]) or '0'

Usage:
>>> f("0")
'0'

>>> f("32.005")
'30+2+0.005'

>>> f("100020003000009000000.0007")
'100000000000000000000+20000000000000000+3000000000000+9000000+0.0007'

>>> f("1000000000009000000.0007000000000000000002")
'1000000000000000000+9000000+0.0007+2e-22'

>>> f("0001.99")
'1+0.9+0.09'

Nice. Fails the f('0') test case however, and when I copy and paste straight into my interpreter I get the scientific notation (which I think is fine). Also, list(c) is shorter. If you concatenate the '.' before turning it into a list you don't need to add [] either. Using find instead of index on the string before turning it into a list, after adding '.' also saves you a byte. Reordering the inequality allows you to remove an additional space too: def f(x):x+='.';i=x.find('.');z=list(x);del z[i];return"+".join([str(int(o)*10**(i-j-1))for j,o in enumerate(z)if"0"<o])or'0'

Stax, 18 bytes
ºî≤FlφLfÜG→\ΦUq╜♥←

Run and debug it
Unpacked, ungolfed, and commented, it looks like this.
c           copy input
!C          terminate if input is falsy
y{          for each character in the string input...
  y.\d'0R   replace each digit in the input with "0"
  ia&       then replace the nth character back to its original value
  e         eval as float
m           map using block to produce array
{f          filter out zeroes
'+*         join with "+"

Run this one
Like the many of the other solutions posted, it produces 9000000+9e-7 for the last test case.  According to established precedent this is allowed because the test case is too precise for the language.

C, 253 bytes
m(char*i){int k,j=0,s=0,d=0;while(i[s])s++;while(i[d]!=46)d++;while(j<d){if(i[j]!=48){for(k=0;k<(d-j);k++)putchar(k?48:i[j]);putchar(43);}j++;}while(++j<s)if(i[j]!=48){putchar(46);for(k=0;k<(j-d);k++)putchar(k==(j-d-1)?i[j]:48);putchar(43);}putchar(8);}

Note: putchar(8) should perform a backspace.
 Input: 1230.0456
Output: 1000+200+30+.04+.005+.0006

Detailed, try here
while(i[s]) s++;
while(i[d]!=46) d++;

while (j<d)
{
    if (i[j]!='0')
    {
        for(k=0;k<(d-j);k++) putchar(k? '0': i[j]);
        putchar(43);
    }
    j++;
}

while (++j<s)
if (i[j]!='0')
{
    putchar(46);
    for(k=0; k<(j-d); k++) putchar(k==(j-d-1)? i[j]: '0');
    putchar(43);
}

putchar(8);

Lua, 350 Bytes
I think there's two way to golf it down further :

I could make use of macro.define to replace some of the commons expressions (can't test right now, and not sure it would make me gain some bytes)
Use split on the dot instead of iterating on the whole string. Once again, I'm not sure it would reduce the size of this function, as manipulating string in lua is quite painful.

function f(s)v,r=s:find("%.")or#s+1,""if #s==1 then return s end for i=1,#s do a=""(v>i and s:sub(i,v-1)or s:sub(v,i)):gsub(".",function(c)a=a..(not a:find(c)and(c==s:sub(i,i)or c==".")and c or 0)end)s,r=vi and s:sub(i,v-1)or s:sub(v,i)-- only send the integer OR decimal part to gsub
      ):gsub(".",function(c)          -- iterate over each character of s:sub()

    -- a contains the next number to be concatenated to the string r(the one to be returned)
      a=a..(not a:find(c)             -- we concatenate a with c if a doen't contains
        and(c==s:sub(i,i)or c==".")   -- c, and c is either a dot, or the next number
             and c or 0)              -- to be add, we put a 0 otherwise
    end)
    -- we concatenate the new a with the string already formed
    r=r..((#a==a:find("%.")           -- if a=="." or a's value is 0
            or tonumber(a)==0)and""   -- we concatenate an empty string
      or a:gsub("%.","0.")            -- else, we replace the (possible) leading dot by "0."
      ..(i~=#s and"+"or""))           -- and concatenate a "+" if it isn't the last number to be added

    s=vi and s:sub(i,v-1)or s:sub(v,i)):gsub(".",function(c)a=a..(not a:find(c)and(c==s:sub(i,i)or c==".")and c or 0)end)s,r=v<i and s:sub(0,i-1).."0"..s:sub(i+1,#s)or s,r..((#a==a:find("%.")or tonumber(a)==0)and""or a:gsub("%.","0.")..(i~=#s and"+"or""))end return r end

print(f("3123.12333"))
print(f("9545"))
print(f("9000000.0000009"))
print(f("6"))

sed, 136 128 bytes
Reduced by 8 chars by dropping spaces and useless 0.
:;s/^([1-9][0-9]*)([1-9])(0*)([+.].*|)$/\10\3+\2\3\4/;s/([1-9]0*)\.([0-9])/\1+.\2/;s/\.(0*)([1-9])([0-9]*[1-9])$/.\1\2+.\10\3/;t

Test cases:
sed -r ':;
    s/^([1-9][0-9]*)([1-9])(0*)([+.].*|)$/\10\3+\2\3\4/;
    s/([1-9]0*)\.([0-9])/\1+.\2/;
    s/\.(0*)([1-9])([0-9]*[1-9])$/.\1\2+.\10\3/;
    t' <<<$'0\n6\n0.99\n24601\n6.283\n9000000.0000009\n3.1415'
0
6
0.9+.09
20000+4000+600+1
6+.2+.08+.003
9000000+.0000009
3+.1+.04+.001+.0005

R - 133 bytes
Robust, ignores Machine Epsilon and works also with trailing zeros.
a) Golfed:
f=function(x)if(x=='0')x else{z=strsplit(x,'')[[1]];i=which(z=='.');n=as.numeric(z[-i])*10^(i-seq(z)[-1]);paste(n[n>0],collapse='+')}

Ungolfed:
f=function(x)
  if(x=='0')
    x
  else {
    z=strsplit(x,'')[[1]]
    i=which(z=='.')
    n=as.numeric(z[-i])*10^(i-seq(z)[-1])
    paste(n[n>0],collapse='+')
  }

Usage:
f("900.008")

JavaScript (ES7), 114 bytes
s=>(p=s.search(/.\b/),i=-1,[for(c of s)if((i++,c>0))(z=s.substring(i,p).replace(/d/g,0),i<p?c+z:z+c)].join`+`||s

Works with arbitrary length numbers because it uses string manipulation throughout.
Without the array comprehension (122 bytes):
s=>[...s].map((c,i)=>c<'1'?'':(z=s.substring(i,p).replace(/\d/g,0),i
x).join`+`||s

Ungolfed:
function expand(s) {
    zeros = s.replace(/\d/g, "0");
    point = s.indexOf(".");
    if (point < 0) point = s.length;
    result = [];
    for (i = 0; i < s.length; i++) {
        if (s[i] > "0") {
            if (i < point) result.push(s[i] + zeros.slice(i, point - 1));
            else result.push(zeros.slice(point - 1, i) + s[i]);
         }
     }
     return result.length ? result.join("+") : s;
}

As far as I know, this new array comprehension syntax is from ECMAScript 7.

@manatwork Thanks, I updated it while I was adding the ungolfed version.


text:
9 Deaths of the Ninja
Inspired by this conversation in chat.
Your goal in this challenge is to emulate a ninja and count how many deaths he has left.
Specs
You ninja starts out with 9 deaths left. He also gets an integral starting health as an input.
Then, he takes as input a list of events in his life that alter his health. These can be negative, positive, or zero integers.
At any point, if his health reaches at or below zero, he loses a life and his health goes back to the starting health.
Your program should report the number of deaths he has left. If he has zero or less left, you should output dead instead.
This is code-golf, so shortest code in bytes wins!
Test Cases
3, [] -> 9
100, [-20, 5, -50, 15, -30, -30, 10] -> 8
10, [-10, -10, -10, -10] -> 5
10, [-10, -10, -10, -10, -10, -10, -10, -10, -10] -> dead
0, [] -> dead
0, [1] -> dead
100, [10, -100] -> 9

YAY!!! My chat post is linked!!! :P

Looks like I'm in trouble...

So the order of events is "die if <=0, read a number, add to total, repeat"?

@ThomasKwa yeah, but the dying can happen multiple times

Can ninjas regenerate like time lords? Please?

Can the starting health be negative?

Jelly, 30 28 26 bytes
»0o⁴+
;@ñ\<1S_9«0N“dead”×?

Try it online!
How it works
;@ñ\<1S_9«0N“dead”×?  Main link. Input: e (events), h (initial health)

;@                    Prepend h to e.
  ñ\                  Reduce the resulting array by the next, dyadic link.
                      This returns the array of intermediate results.
    <1                Check each intermediate value for non-positivity.
      S               Sum. This calculates the number of event deaths.
       _9             Subtract 9 from the result.
         «0           Take the minimum of the result and 0. This yields 0 if no
                      lives are left, the negated amount of lives otherwise.
                   ?  Conditional:
                  ×     If the product of the minimum and h is non-zero:
           N              Return the negated minimum.
            “dead”      Else, return "dead".

»0o⁴+                 Dyadic helper link. Arguments: x, y

»0                    Take the maximum of x and 0.
                      This yields x if x > 0 and 0 otherwise.
  o⁴                  Take the logical OR of the result and the second input (h).
    +                 Take the sum of the result and y.

¯_(ツ)_/¯ Dennis wins

Japt, 40 39 32 bytes
U¬©(9-Vf@T=X+(T¬²ªU)<1} l)¬²ª`Ü%

Try it online!
How it works
While trying to golf this last night (away from a computer, no less), I ran across an interesting replacement for >0: ¬. On numbers, this takes the square root, which returns NaN for negative numbers. NaN is falsy, so this returns exactly the same truthily/falsily as >0.
Extending this trick a little further, we can reset T to U iff it's >=0 in only five bytes: T¬²ªU. How does this work? Let's take a look:
T    ¬      ²       ªU
     sqrt   square  if falsy, set to U (JS's || operator)
4    2      4       4
7   ~2.646  7       7
0    0      0       U
-4   NaN    NaN     U
-7   NaN    NaN     U

As you can see, T¬² returns NaN if T is negative; otherwise, it returns T. Since NaN and 0 are both falsy, this provides an easy way to reset the ninja's health with ªU. This trick is also used to return the ninja's lives left if that number is positive, or "dead" if negative.
Putting this all together:
           // Implicit: U = starting health, V = events, T = 0
U¬©        // If U is positive,
Vf@     }  // Filter out the items X in V that return truthily from this function:
 T=X+      //  Set T to X plus
 (T¬²ªU)   //   If T is positive, T; otherwise, U.
           //  This keeps a running total of the ninja's health, resetting upon death.
 <1        //  Return (T < 1).
9-    l)   // Take the length of the resulting array and subtract from 9.
           // This returns the number of lives the ninja has left.
¬²         // If the result is negative, set it to NaN.
ª`Ü%       // If the result of EITHER of the two parts above is falsy, return "dead".
           //  (`Ü%` is "dead" compressed.)
           // Otherwise, return the result of the middle part (lives left).
           // Implicit: output last expression

If the input is guaranteed to be non-negative, or even positive, we can golf of 1 or 4 bytes:
U©(9-Vf@T=X+(T¬²ªU)<1} l)¬²ª`Ü%  // U is non-negative
9-Vf@T=X+(T¬²ªU)<1} l)¬²ª`Ü%     // U is positive

JavaScript ES6, 62 60 58 bytes
Saved 4 bytes thanks to @ETHproductions
(a,b,d=9,l=a)=>b.map(i=>l=l+i<1?d--&&a:l+i,a)|d<1?"dead":d

Try it online (All browsers work)
Explanation
(a,b,    // a = 1st input, b = 2nd input
 d=9)=>  // Lives counter

  (b.reduce((l,i)=>     // Loop through all the health changes
    l+i<1                 // If (health + health change) < 1
    ?(d--,a)              // Decrease life, reset health
    :l+i                  // Return new health
  ,a)                   // Sets starting health to `a`
  ,d<1?        // Lives is less than 1
   "dead":d);  // Output "dead" otherwise lives left

Would d--&&a work, or b.reduce(...)&&d<1?"dead":d?

map beats reduce in most scenarios: (a,b,d=9,l=a)=>b.map(i=>l=l+i<1?d--&&a:l+i)&&d<1?"dead":d is 57.

@ETHproductions thanks, I don't think .reduce(...)&& would work because of .reduce returns 0, it won't work.

Would (a,b,d=9,l=a)=>b.map(i=>l=l+i<1?d--&&a:l+i,a)|d<1?"dead":d work instead?

CJam, 35 bytes
q~_@{+_1<{W$}&}/](\,_A<@*A@-"dead"?

Try it online!

Haskell, 81 77 75 bytes
p l i h a|l<1="dead"|i<1=p(l-1)h h a|[]<-a=show l|x:y<-a=p l(i+x)h y
p 10 0

Usage example: p 10 0 100 [-20, 5, -50, 15, -30, -30, 10] -> "8"

MATL, 32
9yi"@+t0>~?x1-y]]g*wxt0>~?x'dead'

Explanation
9        # push 9
y        # duplicate 2nd value to top (there is none -> get it from input first)
i        # get input and push it

The stack now looks like this (for input 100, [-20, 5, -50, 15, -30, -30, 10]):
100        9        100        [-20, 5, -50, 15, -30, -30, 10]

reload   deaths    health
value    left

Pop the array and loop
"            ]    # loop
 @+               # add to health
   t0>~?    ]     # if health is zero or less
        x1-y      # delete health counter, decrement life counter, reload health

If the health is zero, set death counter to zero. Special case handling for initial health = 0.
g        # health to bool
*        # multiply with death counter

Delete the reload value from stack
wx

If the death counter is zero or less, delete it and print 'dead' instead.
t0>~?x'dead'

Python 2.7, 82 66 55 106 bytes
Thanks to @RikerW for -16 bytes.:(
Thanks to @Maltysen for -11 bytes. :(
i=input;h=[i()]*9;d=i()
if 0==h[0]:print'dead';exit()
for x in d:
 h[0]+=x
 if h[0]<=0:h=h[1:]
y=len(h)
print['dead',y][y!=0]

First type health, then enter, then events in list form.

TeaScript, 36 34 31 bytes
yR#l+i<1?e─·x:l+i,x);e≥0?e:D`Ü%

Similar to my JavaScript answer. the last 4 characters are the decompression of the string "dead".
TeaScript's online interpreter doesn't support array input so you're going to need to open the console, and run this by typing:
TeaScript( `yR#l+i<1?(e─,x):l+i,x);─e>0?e:D\`Ü%` ,[
  10, [-10, -10, -10, -10]
],{},TEASCRIPT_PROPS);

Explanation
      // Implicit: x = 1st input, y = 2nd input
yR#   // Reduce over 2nd input
  l+i<1?  // If pending health is less then 1
  (e─,x): // then, decrease life counter, reset health
  l+i     // else, modify health
,x);  // Set starting health
─e>0? // Ninja is alive?
e:    // Output lives left
D`Ü%  // Decompress and output "dead"

Pyth, 32
 u+?>GZG&=hZQH+E0Q?&Q<Z9-9Z"dead

Note that there is a leading space. This probably isn't the best approach, but it was the first thing that came to mind. It reduces over input by adding the values to the ninja's health, and incrementing a counter and resetting the health when it drops below zero. We add a zero to the end of the list to count if the last change kills the ninja, and then just do some checking to see if the ninja is dead. The zero starting health case is hard coded.
Test Suite

C# 207
class P{static void Main(string[]a){int h=int.Parse(a[0]),H=h,l=9,i=1;if(a.Length!=1){for(;i<a.Length;i++){H+=int.Parse(a[i]);if(H<=0){l--;H=h;}}}System.Console.Write(h==0?"dead":l<=0?"dead":l.ToString());}}

Takes the input through argument stream. The first argument is the amount of health and all the rest is the list of events.
Readable / ungolfed version
class Program
{
    static void Main(string[]a)
    {
        int health = int.Parse(a[0]);
        int Health = health;
        int lives = 9;

        if(a.Length!=1)
        {
            for (int i = 1;i < a.Length;i++)
            {
                Health += int.Parse(a[i]);
                if (Health <= 0)
                {
                    lives--;
                    Health = health;
                }
            }
        }

        System.Console.Write(health == 0 ? "dead" : lives <= 0 ? "dead" : lives.ToString());
    }
}

Examples:

CSharp.exe 3  =>  9
CSharp.exe 100 -20 5 -50 15 -30 -30 10    =>   8

(Psst.) CSharp.exe is name used as an example. You have to call like this in reality: [program_name.exe] arguments, without the square parentheses.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Smooth vs. Chunky vs. Broken Squiggles
Based on Chunky vs. Smooth Strings.
Squiggles /\_/\/\__/\/\/\/\_/\_/\ are fun to make on a keyboard when you are really bored.  But not all squiggles are created equal.  Some squiggles are smooth, like \___/, and some are chunky, like /\/\/\/\.  Others are just downright broken, like ////_\\\
Inside every squiggle of N characters, there are N-1 squiggle-junctions.  Each squiggle-junction is classified into one of three types:

Smooth (angle > "90 degrees"):
\_  __  _/

Chunky (angle = "90 degrees")
/\  \/

Broken (anything that doesn't connect)
//  \\  /_  _\

Let's define the smoothness to be the proportion of junctions that are smooth, with chunkiness and brokenness defined similarly. Each value ranges between 0 and 1. The sum of a squiggle's smoothness, chunkiness, and brokenness is always equal to 1.
For example, the squiggle /\/\\_//\_ has 3 smooth junctions, 4 chunky junctions, and 2 broken junctions.  It is thus 0.3333 smooth, 0.4444 chunky, and 0.2222 broken.
Empty strings and strings with only one character have undefined values, all input will be at least 2 characters long.
Challenge
Write a program that takes in a squiggle of arbitrary length and outputs any two of its smoothness, chunkiness, and brokenness values.

You may write a program or function, with input via STDIN, command line, or as a string argument.
You may assume the input is at least of length >= 2 and consists only of the characters /\_ with an optional trailing newline.
Print (or return if a function) the two floats to a precision of at least 4 decimals, rounded or truncated.  If the true value is 2/3, acceptable values include any value between 0.6666 and 0.6667, even things like 0.666637104.  If the exact value is 1/3, any answer containing 0.3333 is valid.  You may leave off trailing zeros, or the leading zero if the value is less than one.
Output any pair of the three values as you prefer, just be sure to state which two and in what order.

The shortest code in bytes wins.
Examples
/\/\\/\//\\ → Smoothness 0, Chunkiness 0.7, Brokenness 0.3
_/\\_/\\/__/\\\//_ → Smoothness 0.29411764705, Chunkiness 0.29411764705, Brokenness 0.41176470588
//\\__/_\/ → Smoothness 0.3333333, Chunkiness 0.2222222, Brokenness 0.4444444
Bonus question: Which do you prefer, smooth or chunky or broken squiggles?

Could there be a bonus for outputting all three, or do you have a specific reason for choosing only two?

@Callodacity 2 are sufficient to define the 3rd since they sum to 1

@trichoplax good point - obviously I've been golfing too long, I can't comprehend simple things anymore :P

Pyth, 25 bytes
mcl@.:d2.:z2tlzc2"\__//\/

Test suite
Outputs smoothness, chunkiness. Basically, it takes the hard coded string and cuts it in half. Each half is decomposed into its 2 character substrings, and the same is done for the input. We take the intersection, resulting in the south and chunky pairs. Then, we take the the length, divide by the number of pairs, and print.

Japt, 42 bytes
U=U¬ä@2+"\\/\\__/"bX+Y)f2};[T2]£U¬fX l /Ul

Outputs brokenness, chunkyness. Try it online!
How it works
            // Implicit: U = input string
U=U¬ä@   }  // Set U to U split into chars, with each pair mapped by this function:
"..."bX+Y)  // Take the index in this string of the two chars concatenated.
            // This is 0-1 for chunky, 2-4 for smooth, and -1 for broken.
2+    f2    // Add two and floor to the nearest multiple of 2.
            // This is now 2 for chunky, 4 or 6 for smooth, and 0 for broken.
[T2]£       // Map each item X in [0,2] through this function:
U¬fX l      //  Count the occurances of X in U.
/Ul         //  Divide by U.length.
            // Implicit: output last expression

Non-competing version, 36 bytes
U=Uä@2+"\\/\\__/"bZ)f2};[T2]£UèX /Ul

Works in basically the same way as the other, with a few minor changes:

ä now works on strings. The chars are passed into the function in order (X, Y, X+Y).
è counts the number of occurrences of the argument in the string/array.

Ruby, 71
Outputs smoothness, chunkiness.
Takes the minimal smooth and chunky strings and searches them for every two-character string in the initial string.
Thanks to Kevin Lau for EIGHT bytes!
->x{%w{\\__/ /\\/}.map{|t|(0..n=x.size-2).count{|i|t[x[i,2]]}/(n+1.0)}}

(0..x.size-2).count{|i|t[x[i,2]]} saves 5 bytes over x.chars.each_cons(2).count{|i|t[i*'']}. And now that you're using x.size twice in the function, assigning it to a variable and using that saves an extra byte.

@KevinLau Managed to save 8 bytes using your approach.  Thanks!

Python 3, 149 bytes
This outputs smoothness and chunkyness.
def f(s):
 for i in"012":s=s.replace("\_/"[int(i)],i)
 a=len(s)-1;t=["bscbssbbc"[int(s[i:i+2],3)]for i in range(a)]
 for x in"sc":print(t.count(x)/a)

Ungolfed:
def f(s):
    for i in "012":
        s = s.replace("\_/"[int(i)], i)
    a = len(s) - 1
    t = []
    for i in range(a):
        t.append("bscbssbbc"[int(s[i:i+2],3)])
    for x in "sc":
        print(t.count(x) / a)

Python 3.8 (pre-release), 82 79 bytes
lambda x:[sum(a+b in s for a,b in zip(x,x[1:]))/~-len(x)for s in["\__/","/\/"]]

Try it online!

-3 from @xnor by not using index i into array

Python, 90 bytes
f=lambda x,s=0,c=0,n=0:x[1:]and f(x[1:],s+(x[:2]in"\__/"),c+(x[:2]in"/\/"),n+1)or(s/n,c/n)

Attempt This Online!
Recursive solution -- longer, but I think it's more elegant.

-3 bytes by cutting out the index i

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Build ASCII ladders
Given an input of two integers n and m, output an ASCII ladder of length
n and size m.
This is an ASCII ladder of length 3 and size 3:
o---o
|   |
|   |
|   |
+---+
|   |
|   |
|   |
+---+
|   |
|   |
|   |
o---o

This is an ASCII ladder of length 5 and size 1:
o-o
| |
+-+
| |
+-+
| |
+-+
| |
+-+
| |
o-o

This is an ASCII ladder of length 2 and size 5:
o-----o
|     |
|     |
|     |
|     |
|     |
+-----+
|     |
|     |
|     |
|     |
|     |
o-----o

To be specific:

The length (n) represents how many squares the ladder is made up of.
The size (m) represents the width and height of the interior of—that is,
not counting the "borders"—each square.
Each square is made up of the interior area filled with spaces, surrounded by
-s on the top and bottom, |s on the left and right, and +s at all four
corners.
Borders between squares merge together, so two lines in a row with
+--...--+ merge into one.
The corners of the entire ladder are replaced with the character o.
You may optionally output a trailing newline.

The length of the ladder (n) will always be ≥ 2, and the size (m) will
always be ≥ 1.
Input can be taken as a whitespace-/comma-separated string, an array/list/etc.,
or two function/command line/etc. arguments. The arguments can be taken in
whichever order is most convenient / golfiest.
Since this is code-golf, the shortest code in bytes wins.
Tip: The examples above can also be used as test cases.

Do we have to take length first, then size?

@RK. You can take them in whichever order is more convenient.

Can there be a leading newline?

@CᴏɴᴏʀO'Bʀɪᴇɴ Uhh... I'm going to go with no on that one.

Okay :P It was worth a shot.

Hey, issacg's Pyth answer is shorter! Not mine!

@ChristianIrwan ... oh, whoops, I can't count. Fixed.

Pyth, 34 bytes
.NjjNm*QTvz*2YjC:M++J"+|o"m"- -"QJ

Test suite
Takes arguments newline separated on STDIN.
Uses a helper function, :, which builds each type of vertical string from three characters, then replicates as necessary, transposes and joins on newlines.

Ruby, 71
->m,n{h=0;(?o+?+*(n-1)+?o).chars{|c|puts [?|+' '*m+?|]*h,c+?-*m+c;h=m}}

ungolfed in test program
f=->m,n{
  h=0                             #The number of | above the 1st rung is 0
  (?o+?+*(n-1)+?o).chars{|c|      #Make a string of all the rung ends o++...++o and iterate through it
    puts [?|+' '*m+?|]*h,         #draw h vertical segments |  ...  |
      c+?-*m+c                    #and a rung with the correct ends
    h=m                           #The number of | above all rungs except the 1st is m
  }
}

f[gets.to_i,gets.to_i]

There seems to be minor issues with the golfed version: need ; after h=0, need space after puts. But you score grows only with 1 character as there is an extra space before puts.

@manatwork oops, thanks, fixed. I don't know how that happened, I must have golfed and not run it afterwards.

CJam, 43 42 bytes
I'm not sastified by the score. But I'm not Dennis, right?
q~:Z;'-'o{[\Z*1$N]}:X~['-_'+X\'|XZ*]@*1>1$

Input is 2 space separated items. Length first
2 3
o---o
|   |
|   |
|   |
+---+
|   |
|   |
|   |
o---o

Explanation
q~:Z;'-'o{[\Z*1$N]}:X~['-_'+X\'|XZ*]@*1>1$
q~                                         e# read input
  :Z;                                      e# Record the size in Z and discard
     '-'o{[\Z*1$N]}:X~                     e# Create the initial line (and final). also creates a shorcut to do this later
           \                               e# Capture two arguments
            Z*                             e# The separator is repeated size times
              1$                           e# Repeat the first argument
                N                          e# Add newline
                                           e# X is a function to create line in a ladder
                      ['-_'+X\'|XZ*]       e# Design the repeating part
                                    @*     e# Repeat the pattern n times
                                      1>   e# Discard the initial
                                        1$ e# Since the final line is same than the initial, we just write it.
                                           e# Implicit printing

I like that you worded it as a question. "I'm not Dennis... right?"

JavaScript (ES6), 89
... repeat, repeat, repeat ...
(n,m,R=x=>x.repeat(m),b=R(`|${R(' ')}|
`),d=`o${c=R('-')}o
`)=>d+R(b+`+${c}+
`,m=n-1)+b+d

Test

F=(n,m,R=x=>x.repeat(m),b=R(`|${R(' ')}|
`),d=`o${c=R('-')}o
`)=>d+R(b+`+${c}+
`,m=n-1)+b+d

// Less golfed
U=(n,m)=>
{
  var R=x=>x.repeat(m),
      a=R(' '),
      b=R(`|${a}|\n`);
      c=R('-'),
      d=`o${c}o\n`;
  m=n-1;
  return d+R(b+`+${c}+\n`)+b+d
}

function test() {
  var i=I.value.match(/\d+/g)
  if (i) O.textContent=F(+i[0],+i[1])
  console.log(i,I.value)
}

test()
N,M: <input id=I value="3,5" oninput=test()>

I did'nt know that document.getElementById('elem'). could be replaced by elem. ! +1 for this, but please, could you point out some docs about this?

@F.Hauri it works in almost every browser, but should be avoided (except when coding for fun). Info and links http://stackoverflow.com/questions/3434278/do-dom-tree-elements-with-ids-become-global-variables

C#, 1412 bytes
... My first CodeGolf attempt, Not likely to win but it works so here we go:
using System;

namespace Ascii_Ladders
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0;
            int m = 0;

            Console.Write("Please enter Height: ");
            n = int.Parse(Console.ReadLine());
            Console.Write("Please Enter Width: ");
            m = int.Parse(Console.ReadLine());

            Console.Write("o");
            for (int i = 0; i < m; i++)
            {
                Console.Write("-");
            }
            Console.WriteLine("o");

            for (int k = 0; k < n; k++)
            {
                for (int i = 0; i < m; i++)
                {
                    Console.Write("|");
                    for (int j = 0; j < m; j++)
                    {
                        Console.Write(" ");
                    }
                    Console.WriteLine("|");
                }
                if (k != n - 1)
                {
                    Console.Write("+");
                    for (int i = 0; i < m; i++)
                    {
                        Console.Write("-");
                    }
                    Console.WriteLine("+");
                }
            }

            Console.Write("o");
            for (int i = 0; i < m; i++)
            {
                 Console.Write("-");
            }
            Console.WriteLine("o");

            Console.ReadKey();
        }
    }
}

Welcome to Programming Puzzles & Code Golf! You have a lot of whitespace in your code that you can remove to shorten your code, if you would like more help golfing your code, you can check out Tips for golfing in C#.

I agree with @Doᴡɴɢᴏᴀᴛ here. I've been able to potentially golf it to just 533 bytes. But it could be better. (Warning: I don't program in C#.)

I got it down to 314 with using System;class P{static int m;static void Main(){int n = int.Parse(Console.ReadLine());m = int.Parse(Console.ReadLine());M('o','-');for(int k=0;k<n;k++){for(int i=0;i<m;i++){M('|',' ');}if(k!=n-1){M('+','-');}}M('o','-');Console.ReadKey();}static void M(char x,char y){Console.WriteLine(x+new string(y,m)+x);}}

Missed a few spaces so 310 with using System;class P{static int m;static void Main(){int n=int.Parse(Console.ReadLine());m=int.Parse(Console.ReadLine());M('o','-');for(int k=0;k<n;k++){for(int i=0;i<m;i++){M('|',' ');}if(k!=n-1){M('+','-');}}M('o','-');Console.ReadKey();}static void M(char x,char y){Console.WriteLine(x+new string(y,m)+x);}}

Down to 270 without changes in the approach used: using C=System.Console;class P{static void Main(){int i,k,n=int.Parse(C.ReadLine()),m=int.Parse(C.ReadLine());System.Action<char,char> M=(x,y)=>C.WriteLine(x+new string(y,m)+x);M('o','-');for(k=0;k<n;k++){for(i=0;i<m;i++){M('|',' ');}if(k<n-1){M('+','-');}}M('o','-');}}. There is most likely more potential here, though, simply by changing how to do things a bit.

Julia, 87 bytes
f(n,m)=(g(x)=(b=x[1:1])x[2:2]^m*b*"\n";(t=g("o-"))join([g("| ")^m for i=1:n],g("+-"))t)

This is a function that accepts two integers and returns a string.
Ungolfed:
function f(n::Int, m::Int)
    # Create a function g that takes a string of two characters and
    # constructs a line consisting of the first character, m of the
    # second, and the first again, followed by a newline.
    g(x) = (b = x[1:1]) * x[2:2]^m * b * "\n"

    # Assign t to be the top and bottom lines. Construct an array
    # of length n where each element is a string containing the
    # length-m segment of the interior. Join the array with the
    # ladder rung line. Concatenate all of this and return.
    return (t = g("o-")) * join([g("| ")^m for i = 1:n], g("+-")) * t
end

pb - 147 bytes
^t[B]>>[B]vw[T!0]{b[43]<[X]b[43]>w[B=0]{b[45]>}v[X-1]w[B=0]{b[124]^}v[X]t[T-1]}t[111]b[T]<w[X!0]{b[45]<}b[T]w[Y!0]{w[B!0]{^}b[124]^}b[T]^>>[B]vb[T]

This is the kind of challenge that, by rights, pb should be really good at. Drawing simple pictures with characters is exactly what pb was designed for. Alas, it's just a wordy language I guess.
Takes input length first, followed by size. Takes input in the form of byte values, for example: python -c 'print(chr(5) + chr(7))' | ./pbi.py ladder.pb
Look, a fun animation!

With comments:
^t[B]            # Save length to T
>>[B]v           # Go to X=size+1, Y=0

w[T!0]{          # While T is not 0:
    b[43]            # Write a '+'
    <[X]b[43]        # Write a '+' on the left side as well
    >w[B=0]{b[45]>}  # Travel back to the right '+', writing '-' on the way
    v[X-1]           # Go down by X-1 (== size)
    w[B=0]{b[124]^}  # Travel back up to the '+', writing '|' on the way
    v[X]             # Go down by X (== size + 1, location of next '+')
    t[T-1]           # Decerement T
}

t[111]           # Save 'o' to T (it's used 4 times so putting it
                 # in a variable saves bytes)

b[T]             # Write an 'o' (bottom right)

<w[X!0]{         # While not on X=0:
    b[45]<           # Travel left, writing '-' on the way
}

b[T]             # Write an 'o' (bottom left)

w[Y!0]{          # While not on Y=0:
    w[B!0]{^}        # Skip nonempty spaces
    b[124]           # Write a '|'
    ^                # Travel up
}

b[T]             # Write an 'o' (top left, replaces existing '+')

^>>[B]v          # Go back to where the size is saved and go to X=size+1, Y=0

b[T]             # Write an 'o' (top right, replaces existing '+')

Pure bash, 132 130 128 127 bytes
Yes I could drop 1 more byte replacing last ${p% *}, but I prefer this:
p=printf\ -v;$p a %$1s;$p b %$2s;o="|$a|\n";h=+${a// /-}+\\n v=${a// /$o}
a=${b// /$h$v}${h//+/o};a=${a/+/o};${p% *} "${a/+/o}"

Sample:
ladders() {
    p=printf\ -v;$p a %$1s;$p b %$2s;o="|$a|\n";h=+${a// /-}+\\n v=${a// /$o}
    a=${b// /$h$v}${h//+/o};a=${a/+/o};${p% *} "${a/+/o}"
}

ladders 3 4
o---o
|   |
|   |
|   |
+---+
|   |
|   |
|   |
+---+
|   |
|   |
|   |
+---+
|   |
|   |
|   |
o---o

ladders 2 1
o--o
|  |
|  |
o--o

Haskell, 100 97 bytes
l#s=unlines$t:m++[t]where _:m=[1..l]>>["+"!"-"]++("|"!" "<$u);t="o"!"-";o!i=o++(u>>i)++o;u=[1..s]

Usage example:
*Main> putStr $ 4 # 3
o---o
|   |
|   |
|   |
+---+
|   |
|   |
|   |
+---+
|   |
|   |
|   |
+---+
|   |
|   |
|   |
o---o

How it works:
l#s=unlines$t:m++[t]         -- concat top line, middle part and end line
                             -- with newlines between every line
  where                      -- where
  _:m=                       -- the middle part is all but the first line of
     [1..l]>>                -- l times
         ["+"!"-"]           --    a plus-dashes-plus line
         ++("|"!" "<$u)      --    followed by s times a bar-spaces-bar line

  t="o"!"-"                  -- very first and last line
  o!i=o++(u>>i)++o           -- helper to build a line
  u=[1..s]

Edit: @Christian Irwan found 3 bytes. Thanks!

Patternmatching for -1 score m=init$[1..l]>>("|"!" "<$u)++["+"!"-"] => (_:m)=[1..l]>>["+"!"-"]++("|"!" "<$u)

Surprisingly_:m=[1..l]>>["+"!"-"]++("|"!" "<$u) works

@ChristianIrwan: well spotted! Thanks!

PowerShell, 77 80
param($l,$s)$a='-'*$s
($c="o$a`o")
(($b=,"|$(' '*$s)|"*$s)+"+$a+")*--$l
$b
$c

77 bytes

brainfuck - 334 bytes
,[<+<<<<+>>>>>-]<[[>>]+[<<]>>-]<----[>---<----]--[>[+>>]<<[<<]>++++++]>[+.>>]-[<+>---]<+++++++>>--[<+>++++++]->---[<------->+]++++++++++[<++<]+++++[>[++++++>>]<<[<<]>-]>[-]>.-<<----[>>+++<<----]--[>+<--]>---<<<<++++++++++.,[>[>+>+<<-]>[<+>-]>[<<<<[>>>>>>[.>>]<<[<<]>>-]>>>>>[.>>]<<[<<]>-]<<<<+>-]>>>>[-]----[>---<----]>+.[>]<<<<<[.<<]

I expected this to be a lot shorter.
This sets up a "string" that looks like |    (...)    | and one that looks like +----(...)----+, printing each one as necessary, with some special casing for the os on the top and bottom.
Requires an interpreter that uses 8-bit cells and allows you to go left from cell 0 (be it into negative cells or looping). In my experience, these are the most common default settings.
With comments:
,[<+<<<<+>>>>>-]<[[>>]+[<<]>>-] Get m from input; make a copy
                      Turn it into m cells containing 1 with empty cells between

<----[>---<----]      Put 67 at the beginning (again with an empty cell between)

--[>[+>>]<<[<<]>++++++]  Add 43 to every nonempty cell

>[+.>>]               Add 1 to each cell and print it

-[<+>---]<+++++++    Put 92 after the last 45 (no empty cell!)

>>--[<+>++++++]      Put 43 immediately after the 92

->---[<------->+]    Put 234 after 43

++++++++++           And 10 after that

[<++<]             Add two to the 234; 92; the empty spaces; and left of the 111

+++++[>[++++++>>]<<[<<]>-] Add 30 to each 2; the 94; and the 236

>[-]>.-<<----[>>+++<<----] Erase leftmost 32; Print 111; subtract 68 from it

--[>+<--]>---        Put 124 where the 32 was

<<<<++++++++++.,     Print a newline; override the cell with n from input

[                    n times:

  >[>+>+<<-]>[<+>-]    Make a copy of m

  >[                   m times:

    <<<<                 Look for a flag at a specific cell

    [                    If it's there:

      >>>>>>[.>>]          Go to the 43; print it and every second cell after

      <<[<<]>>-            Clear the flag

    ]

    >>>>>[.>>]           Go to the 124; print it and every second cell after

    <<[<<]>              Go back to the copy of m

  -]

  <<<<+>               Plant the flag

-]

>>>>

[-]----[>---<----]>+ Erase the 124; add 68 to 43

.[>]                 Print it; then head to the end

<<<<<[.<<] Go to the last 45; print it; then print every second cell to the left

Perl, 98 bytes
($n,$m)=@ARGV;print$h="o"."-"x$m."o\n",((("|".(" "x$m)."|\n")x$m.$h)x$n)=~s{o(-+)o(?=\n.)}{+$1+}gr

An excellent first answer. But I don't see any + signs in your code, have you considered that the intermediate rungs have + signs at each end?

Thank you for the very nicely worded comment--I totally spaced the plus signs!  Cost me quite a bit of space, too; still thinking of how I can shorten it... besides omitting the ($n,$m)=@ARGV; and assuming those are set already--not sure if that's in the spirit or not.  I'll have to look it up.

Unless otherwise specified in the question, the rule is here http://meta.codegolf.stackexchange.com/a/2422/15599 . You can't just assume the variables are set, but you can write a function instead of a program, if that helps. I don't do Perl but I assume that might save you the @ARGV. Also, when replying to someone remember to include @username so they get an alert. I don't need to do it as this is your post.

Jolf, 36 bytes
Try it here!
ρpi,a+2J+2J"o-| "j"o(.+)o
o.+o'+$1+

Explanation
ρpi,a+2J+2J"o-| "j"o(.+)o\no.+o'+$1+
 pi              j                   repeat vertically j times
   ,a+2J+2J"o-| "                    a box with dimensions 2+J
ρ                 "o(.+)p\np.+o'     replace with regex
                                +$1+ with the -...-

Tcl, 187 bytes
lassign $argv n w
set c 0
while { $c < [expr {($w * $n) + ($n + 2)}]} {if {[expr {$c % ($n + 1)}] == 0} {puts "o[string repeat "-" $w ]o"} else {puts "|[string repeat " " $w ]|"}
incr c}

This code is made to put into a file with arguments input on the command line.  provide number of boxes and width in that order.

PHP, 81bytes
Expects 2 arguments, passed when calling the PHP command directly. The first one is the size and the 2nd one is the number of steps.
$R=str_repeat;echo$P="o{$R('-',$W=$argv[1])}o
",$R("|{$R(' ',$W)}|
$P",$argv[2]);

May require some improvements.

C, 122 bytes
f(int m,int n,char*s){int i=0,w=3+m++;for(;i<w*m*n+w;++i)*s++=i%w>m?10:" |-+-o"[!(i/w%m)*2+!(i%w%m)+!(i/w%(m*n))*2];*s=0;}

Try it online.

Vyxal, 30 bytes
(‛+on¬i:⁰-p,⁰(\|:⁰꘍p,))\o:⁰-p,

Try it Online!
(                     )        # Length times...
 ‛+on¬i                        # If first iteration, o, else +
       :                       # Duplicate
        ⁰-                     # add (size) minuses
          p,                   # Add the o/+ and print
            ⁰(       )         # Size times
              \|               # A pipe character
                :              # Duplicate
                 ⁰꘍            # Add (size) spaces
                   p,          # Add the pipe and print
                       \o:     # Push two os
                          ⁰-   # Add (size) minuses
                            p, # Add the o and print

-2 bytes

Python 2, 94 bytes
def F(n,m):a,b,c,d='o|+-';r=[a+d*m+a]+([b+' '*m+b]*m+[c+d*m+c])*n;r[-1]=r[0];print'\n'.join(r)

'Ungolfed':
def F(n,m):
 # 'o---o'
 r = ['o'+'-'*m+'o']
 # ('|   |'*m+'+---+') n times
 r += (['|'+' '*m+'|']*m+['+'+'-'*m+'+'])*n
 # replace last +---+ with o---o
 r[-1] = r[0]
 print '\n'.join(r)

Perl 5, 91 + 1 (-a) = 92 bytes
$_='|'.$"x$F[1].'|';push@a,y/| /+-/r,($_)x$F[1]while$F[0]--;$a[0]=y/| /o-/r;say for@a,$a[0]

Try it online!

Pip -l, 35 bytes
(^YsXbRLaJW'-)XbWR^('|XbRLaJ'+)WR'o

Try it online!
Explanation
(^YsXbRLaJW'-)XbWR^('|XbRLaJ'+)WR'o
                                     a is length, b is size, s is space (implicit)
   sXb                               String containing b spaces
      RLa                            List containing a copies of that string
         JW'-                        Join on "-" and wrap the result in "-" as well
  Y                                  Necessary for operator precedence reasons
 ^                                   Split into a list of characters
(            )Xb                     String-repeat each character in the list b times
                                     This list represents the central columns of the ladder

                    '|Xb             String containing b pipe characters
                        RLa          List containing a copies of that string
                           J'+       Join on "+"
                   (          )WR'o  Wrap in "o"
                  ^                  Split into a list of characters
                                     This list represents the outer columns of the ladder

                WR                   Wrap the left list in the right list, vectorizing

Some other versions
I tried a lot of different approaches trying to catch Pyth...
[Y'-XbWR'o;@>(sXbWR'|RLbPE'-XbWR'+RL:a)y]  41
Y^(t**b.1*:t**bX--a.1)" --"@yXbWR"|o+"@y   40
Y'|XbRLaJ'+YyWR'o;Z:sXbRLaJW'-RLbPEyAEy    39
t**:b(" |-o-+"<>2)@_@^t.1M$*Y[ttXa-1].1    39
J*Z:sXbRLaJW'-RLbWR:^('|XbRLaJ'+)WR'o      37
Y^$*Y[t**:btXa-1].1" --"@yXbWR"|o+"@y      37

I'm particularly fond of the t**b ones, which use math to generate the ladder's vertical pattern:
        b           Size; e.g. 3
    t               Preset variable for 10
     **:            Set t to t**b (e.g. 1000)
           a        Length; e.g. 3
            -1      2
         tX         String-repeat (the new value of) t 2 times: 10001000
   [          ]     Put t and the above into a list: [1000; 10001000]
               .1   Append 1 to both of them: [10001; 100010001]
$*(              )  Fold on multiplication: 1000200020001

The 1000200020001 can then be used to generate the patterns o|||+|||+|||o and -   -   -   -, which make up the ladder. Unfortunately, I couldn't get this approach to be shorter than the join/wrap approach.


text:
What size is the digit?
7-segment digits can be represented in ASCII using _| characters.  Here are the size 1 digits:
   _  _       _   _   _   _   _   _
|  _| _| |_| |_  |_    | |_| |_| | |
| |_  _|   |  _| |_|   | |_|  _| |_|

Larger sizes are formed by making each segment proportionately longer.  Here are a couple size 3 digits.
 ___    ___    ___    ___    ___    ___    ___
|   |  |          |  |          |  |   |  |   |
|   |  |          |  |          |  |   |  |   |
|___|  |___       |  |___    ___|  |   |  |___|
|   |  |   |      |      |      |  |   |      |
|   |  |   |      |      |      |  |   |      |
|___|  |___|      |   ___|   ___|  |___|   ___|

Goal
In this challenge, you are to write a program/function that can take a single digit as input and identify its size.  The catch: if the input is not a valid digit, then your program should output 0.
This is code-golf, fewest bytes wins.
You can write either a program or a function, which can receive the digit either as STDIN or an argument, and print/return the value.
Digits will be provided as a multi-line string, padded with the minimal amount of trailing whitespace needed to make it a perfect rectangle.  The trailing newline is an optional part of input.  There will be no unneeded leading spaces.
When a non-digit is passed, it will still be comprised of _| characters, padded to a rectangle, and have no unneeded leading spaces. There will be no blank lines. You won't have to deal with empty input.
Output should be a single non-negative integer, with optional trailing newline.  If the input is not a proper digit of any size, output 0.  Else, output the size.
Here is a handy guide for the widths and heights of each digit for a given size N.
Digit  Height  Width (not counting newlines)
1      2N      1
2      2N+1    N+2
3      2N+1    N+1
4      2N      N+2
5      2N+1    N+2
6      2N+1    N+2
7      2N+1    N+1
8      2N+1    N+2
9      2N+1    N+2
0      2N+1    N+2

I/O Examples
In:
__
  |
__|
  |
__|

Out:
2

In:
|
|
|

Out:
0  //because it is of an invalid height.  Either 1 char too short or tall.

In:
|    |
|    |
|    |
|____|
     |
     |
     |
     |

Out:
4

In:
 ___
|
|___
|   |
|___|

Out:
0 //1 char too wide

In:
 _
|_|
| |

Out:
0 //it's not a digit

In:
 __
|
|__
   |
 __|

Out:
2

In:
 _  _
 _| _|
|_  _|

Out:
0  //both would be valid individually, but input should be a *single* digit

In:
 _
|_|
|_|

Out:
1

In:
|
|

Out:
1

In:
__|_
 |
 _ |
  _
|__

Out:
0

This is approximately the inverse of Transform number into 7-segment display pattern, from 3 years back.

@steveverrill There's not really a such thing as a size 0 digit, is there?  Unless you've thought up a way to draw them.

This would be incredibly easy if not for the rule that it must be a valid digit...

@ETHproductions I am aware.

@ETHproductions if it didn't have that requirement, it would be a duplicate of http://codegolf.stackexchange.com/q/19548/15599

Ruby, 250
->x{d=y=0
x.size.downto(0){|n|y=n
a=["|
"*2*n]
"XNRDqpm@A".bytes{|z|p=[?|,' ','']
h=s=""
(n*2).times{|i|
i%n<1&&(d=z>>i/n*3&7)&&h=[?_,' '][d/3%2]*n
s=p[d%3]+h+p[d/6]+"
"+s
h=' '*n}
z!=68&&s=' '*(1-d%3/2)+?_*n+"
"+s
a<<s};puts a
a.index(x)&&break}
y}

Given that there are so many possible invalid inputs, the only way to do this was to generate all the correct digits and check to see if the input matches.
I build each digit up from bottom to top, in 2 halves plus the top line. Although there are 12 possibilities (considering that the left segment can be on, off, or in the case of 3and 7completely absent) only 7 are actually present and careful choice of encoding enables all info (except the top line) to be encoded into a single character.
the digit 1 doesn't really fit the pattern and is handled separately, being used to initialize the array.
Ungolfed in test program
This version uses . instead of spaces for diagnostic reasons.
#Encoding used for half-digits (radix 3,2,2 most significant digit at right)

#000    |_|  0

#100    ._|  1  . = space

#200    X_|  2  X = no space (for digits 3 and 7)

#010    |.|  3

#110    ..|  4

#210    X.|  5

#001    |_.  6

f=->x{d=y=0                                        #d and y required to be intialized for scoping reasons
  x.size.downto(0){|n|y=n                          #Assume max possible size of character = length of input and iterate down through all possible sizes n
    a=["|\n"*2*n]                                  #Make an array containing the digit 1 (different shape to others)
    "XNRDqpm@A".bytes{|z|                          #Each character encodes the pattern for a digit. Iterate through them
      p=['|','.','']                               #Possible components for left and right of digit
      h=s=""                                       #h initialized for scoping reasons. s will contain the digit string
      (n*2).times{|i|                              #For each row
        i%n<1&&                                    #If i%n==1 we are at the bottom of a half digit
        (d=z>>i/n*3&7)&&                           #so extract info from z and store in d
        h=[?_,'.'][d/3%2]*n                        #h is the horizontal part of the half digit, either _ or spaces
        s=p[d%3]+h+p[d/6]+"\n"+s                   #Build one row of digit, working upwards: left,middle,right
        h='.'*n                                    #If row i%n!=0 (not bottom row of half digit)the middle section must contain spaces
      }                                            #We now have both halves of the digit, only the top segment missing
      z!=68&&s='.'*(1-d%3/2)+?_*n+".\n"+s          #If z!=68 (digit 4) add a top to the digit, with appropriate leading and trailing spaces
      a<<s                                         #Add the completed digit of size n to a
    }
    #puts a                                        #Diagnostic: uncomment to print all the strings checked
    a.index(x)&&break                              #If string x is in a, break

  }
y                                                  #and return last value of n
}

# digit 7, size 2. Trailing newline required. Outputs 2
puts f[
"__.
..|
..|
..|
..|
"]


text:
How many peaks in my mountain range?
A list of positive integers can be visualized as a quantized mountain range where each list entry represents the height of one vertical section of the mountains.
For example, the list
1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3

can become the range
      x
    x x
   xxxxx   xxx   x
 xxxxxxxx xxxxxx x
xxxxxxxxxxxxxxxxxx

(Less poetic people might call this a bar chart, but I digress.)
The question in this challenge is: How many peaks are in the mountain range of some arbitrary list? Essentially, how many local maxima are in the list?
A peak is defined as a contiguous section of one or more columns of the mountain range that are all equal in height, where the columns immediately to the left and the right are lower in height.
It's easy to visually tell that the example has four peaks at these parenthesized locations:
1, 2, 2, 3, (4), 3, (5), 3, 2, 1, 2, (3, 3, 3), 2, 2, 1, (3)

Note how the (3, 3, 3) plateau section counts as a peak because it is a contiguous set of columns equal in height, higher than its neighboring columns.
The last (3) counts as a peak as well because, for the purposes of this challenge, we'll define the left neighbor of the leftmost column and the right neighbor of the rightmost column to both be height zero.
This means that a list with only one value, for example 1, 1, 1, can be interpreted as 0, 1, 1, 1, 0, and thus has one peak, not none: 0, (1, 1, 1), 0.
The only list with zero peaks is the empty list.
Challenge
Write a function or program that takes in an arbitrary list of positive integers and prints or returns the number of peaks in the corresponding mountain range.
The shortest code in bytes wins. Tiebreaker is earlier post.
Test Cases
Input List -> Output Peak Count

[empty list] -> 0
1, 1, 1 -> 1
1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3 -> 4
1 -> 1
1, 1 -> 1
2, 2, 2, 2, 2 -> 1
90 -> 1
2, 1, 2 -> 2
5, 2, 5, 2, 5 -> 3
2, 5, 2, 5, 2, 5, 2 -> 3
1, 2, 3, 4 -> 1
1, 2, 3, 4, 1, 2 -> 2
1, 3, 5, 3, 1 -> 1
7, 4, 2, 1, 2, 3, 7 -> 2
7, 4, 2, 1, 2, 1, 2, 3, 7 -> 3
1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 -> 10
1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1 -> 10
2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 -> 10
1, 3, 3, 3, 1, 3, 3, 1, 3, 1, 3, 3, 3, 3, 1 -> 4
12, 1, 2, 1, 2, 3, 3, 3, 2, 4, 4, 4, 1, 5, 5, 4, 7, 9 -> 6
87, 356, 37673, 3676, 386, 909, 909, 909, 909, 454, 909, 909 -> 3
87, 356, 37673, 3676, 386, 909, 909, 909, 909, 454, 909, 908, 909 -> 4

So, the plateau can be arbitrary long?

@nicael Yes, it could be

Can we take input as an array, not as string?

@nicael Yes, anything reasonable

Pyth, 18 bytes
su_>VGtG2eMr++ZQZ8

Based on @PeterTaylor's repeated greater than solution, but with a twist.
++ZQZ: Add zeros on both sides.
eMr ... 8: Remove repeats.
u ... 2 ...: Apply the following twice:
>VGTG: Map each pair of numbers to whether they are in decreasing order.
_: And reverse.
A 1 in the output corresponds to a 1, 0 in prior step, which corresponds to a  c in the input due to the reversal.
s: Sum (and print)

CJam (32 26 24 21 bytes)
0q~0]e`1f=2ew::>2,/,(

Expected input is space-separated numbers.
Online demo ; full test suite (expected output is a 1 per test case).
Thanks to Martin for informing me that the current version of CJam improves one of the operators used, saving 2 chars; and for a further 3-char saving.
Dissection
Two phases: deduplicate, then identify local maxima in each set of three.
0q~0]      e# Put the input in an array wrapped in [0 ... 0]
e`1f=      e# Use run-length encoding to deduplicate
2ew::>     e# Map [a b c ...] to [(a>b) (b>c) ...]
2,/        e# Split on [0 1], which since we've deduplicated occurs when (ac)
,(         e# Count the parts and decrement to give the number of [0 1]s

JavaScript (ES6), 54 51 bytes
m=>m.map(n=>{h=n
p||h;p=n},r=h=p=0)|r+h

Explanation
Takes an array of numbers
m=>
  m.map(n=>{       // for each number n in the mountain range
      h=
        n
p||h;   // if the number is greater than the previous number, set h to 1
      p=n          // set p to the current number
    },
    r=             // r = number of peaks
    h=             // h = 1 if the previous number was higher than the one before it
    p=0            // p = previous number
  )|r+h            // return the output (+ 1 if the last number was higher)

Test

var solution = m=>m.map(n=>{h=n
p||h;p=n},r=h=p=0)|r+h
Mountain Range (space-separated) = <input type="text" id="input" value="87 356 37673 3676 386 909 909 909 909 454 909 908 909" />
<button onclick="result.textContent=solution(input.value.split(' ').map(n=>+n))">Go</button>

Pyth, 25 23 bytes
L._M-M.:b2s<R0y-y+Z+QZZ

Explanation:
L              y = lambda b:
  ._M -M .:          signs of subsets
           b          of b
           2          of length 2. That is, signs of differences.

s <R              number of elements less than
     0              0 in
     y -            y of ... with zeroes removed
         y +          y of
             Z        the input with zeroes tacked on both sides
             + Q Z
       Z

Nice. Unusually, a port to CJam is shorter: 0q~0]{2ew::-:g0-}2*1-, for 22.

Julia, 66
x->(y=diff([0;x;0]);y=y[y.!=0];sum((y[1:end-1].>0)&(y[2:end].<0)))

Pad, differentiate: y=diff([0;x;0]).
Ignore the plateaus: y=y[y.!=0].
Count + to - zero crossings: sum((y[1:end-1].>0)&(y[2:end].<0)).

Mathematica, 42 36 33 32 bytes
Thanks to Martin Büttner for saving 1 byte.
Tr@PeakDetect[#&@@@Split@#,0,0]&

PeakDetect just does almost everything!
Test cases:
Total@PeakDetect[#&@@@Split@#,0,0]&@{12,1,2,1,2,3,3,3,2,4,4,4,1,5,5,4,7,9}
(* 6 *)
Total@PeakDetect[#&@@@Split@#,0,0]&@{87,356,37673,3676,386,909,909,909,909,454,909,908,909}
(* 4 *)

I find my answer to be sufficiently different from yours to post another one.

@LegionMammal978 The result of input {1} is 1, as is expected.

I mean {1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3}

@LegionMammal978 That's tricky. I've not find a solution.

My updated solution just flattens "plateaus".

MATLAB, 29 27 bytes
@(a)nnz(findpeaks([0 a 0]))

Anonymous function which finds the peaks in the data and counts how many there are. 0 is prepended and appended to the data to ensure peaks at the very edges are detected as per the question.
This will also work with Octave. You can try online here. Simply paste the above code into the command line, and then run it with ans([1,2,1,3,4,5,6,1]) (or whatever other input).

As the numbers are always +ve, we can assume they are greater than zero, so can save 2 bytes by using nnz instead of numel.

Python 3, 75 bytes
def m(t):
 a=p=d=0
 for n in t+[0]:a+=(n
p);p=n
 return a

This is my first codegolf so there may be some places to cut down on it, especially the d=((n==p)&d)+(n>p) part. However it works on all the test cases

Are those not 78 bytes?

MATL, 22 bytes
0ih0hdZS49+c'21*?0'XXn

Uses current version of the language/compiler.
Example
>> matl
 > 0ih0hdZS49+c'21*?0'XXn
 >
> [1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3]
4

Explanation
0ih0h           % input array. Append and prepend 0
dZS             % sign of difference between consecutive elements. Gives -1, 0, 1
49+c            % convert to a string of '0','1','2'
'21*?0'XX       % use (lazy) regular expression to detect peaks: '20' or '210' or '2110'...
n               % number of matches. Implicity print

CJam, 27 26 bytes
A0q~0A]e`1f=3ew{~@e>>}%1e=

Uses the run length coding to remove duplicates. After that we check for every triplet if the middle one is the largest number.
Try it here! Passes Peter Taylor's test suite.

Mathematica, 55 39 36 35 bytes
Length@FindPeaks[#&@@@Split@#,0,0]&

Now works on all of the test cases!

Cool! But FindPeaks[#,0,0,-∞] is needed, otherwise it fails for the last test case.

Last/@ saves a byte. And the last ",0" might be unnecessary?

Same trick for you: Last/@ --> #&@@@

Retina, 33 31 bytes
Thanks to Neil for saving 2 bytes.
\b(1+)(?<!\1,\1)(,\1)*\b(?!,\1)

Try it online!
Takes input as a comma-separated, unary list.

\b(1+)(?<!\1 \1)( \1)*\b(?! \1) seems to save 2 bytes?

@Neil of course, thanks! :)

Japt, 19 bytes
That was easier than I thought, but the beginning is slightly wasteful due to a bug.
Uu0;Up0 ä< ä> f_} l

Try it online!
How it works
Uu0;Up0 ä< ä> f_} l  // Implicit: U = input
Uu0;Up0              // Add 0 to the beginning and end of U. If this isn't done, the algorithm fails on peaks at the end.
        ä<           // Compare each pair of items, returning true if the first is less than the second, false otherwise.
                     // This leaves us with a list e.g. [true, false, false, true, false].
           ä>        // Repeat the above process, but with greater-than instead of less-than.
                     // JS compares true as greater than false, so this returns a list filled with false, with true wherever there is a peak.
              f_} l  // Filter out the falsy items and return the length.

Non-competing version, 15 bytes
Uu0 p0 ä< ä> è_

Earlier today, I added the è function, which is like f but returns the number of matches rather than the matches themselves. I also fixed a bug where Array.u would return the length of the array rather than the array itself.
Try it online!

JavaScript ES6, 96 94 bytes
t=>(a=t.filter((x,i)=>x!=t[i-1])).filter((x,i)=>(x>(b=a[i-1])||!b)&&(x>(c=a[i+1])||!c)).length

Principle: collapse plateaus into single peaks, find the picks which are defined as being higher than both next and previous elements.
Takes input as an array.
Demo:

f=t=>
(a=t.filter((x,i)=>x!=t[i-1]))    //collapse every plateau into the pick
    .filter((x,i)=>
       (x>(b=a[i-1])||!b)&&(x>(c=a[i+1])||!c)    //leave only those values which are greater than the succeeding and preceding ones
    ).length

document.write(
  f([])+"
"+
  f([1, 1, 1])+"
"+
  f([1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3])+"
"+
  f([1])+"
"+
  f([1, 1])+"
"+
  f([2, 2, 2, 2, 2])+"
"+
  f([90])+"
"+
  f([2, 1, 2])+"
"+
  f([5, 2, 5, 2, 5])+"
"+
  f([2, 5, 2, 5, 2, 5, 2])+"
"+
  f([1, 2, 3, 4])+"
"+
  f([1, 2, 3, 4, 1, 2])+"
"+
  f([1, 3, 5, 3, 1])+"
"+
  f([7, 4, 2, 1, 2, 3, 7])+"
"+
  f([7, 4, 2, 1, 2, 1, 2, 3, 7])+"
"+
  f([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])+"
"+
  f([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1])+"
"+
  f([2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])+"
"+
  f([1, 3, 3, 3, 1, 3, 3, 1, 3, 1, 3, 3, 3, 3, 1])+"
"+
  f([12, 1, 2, 1, 2, 3, 3, 3, 2, 4, 4, 4, 1, 5, 5, 4, 7, 9])+"
"+
  f([87, 356, 37673, 3676, 386, 909, 909, 909, 909, 454, 909, 909])+"
"+
  f([87, 356, 37673, 3676, 386, 909, 909, 909, 909, 454, 909, 908, 909])
)

MATL, 23
Since we need to use stack based esolangs to be competitive, I reimplemented my Julia solution in MATL.
0i0hhdtg)t5L)0>w6L)0<*s

Push 0, input, 0, concatenate twice. 0i0hh => x = [0, input(''), 0]
Differentiate. d => x = diff(x)
Duplicate t, convert one to boolean and use it to index the other. tg) => x=x(x!=0)
Duplicate again. t
First: [1,G])0> => y1 = x(1:end-1)>0
Exchange. w
Second: [2,0])0< => y2 = x(2:end)<0
Logic and, count the truthy values. *s => sum(y1 & y2)

Or you could you Pyth, a procedural/functional golfing language!

OK, MATL is MATLAB for golfing, but MATLAB is beating MATL.

Very nice! Some tips: [1,G] --> 5L saves 3 bytes. [2,0] --> 6L saves 3 bytes

@GenericUser Not anymore :-) http://codegolf.stackexchange.com/a/69050/36398

@Rainer I'm thinking of removing and (&) from MATL (and same for or). It can always be replaced by *o, and often by just *, as in this case. What do you think? That way the characters & and | could be used for other functions in the future.

@LuisMendo Nice to meet you here :). I observed about MATL that I often use constructions like t0>~?x'default']: Perform a test (mostly for positiveness), if it fails replace it by the default value. Because of the duplication and deletion this takes a lot of bytes. Is there already a short solution to that? If not, something like c#'s null-coalescing operator (??) would be nice. Have a value on the stack, push a default value, apply ??. Only one of both is kept, dependent on the original (now 2nd) value.

@RainerP. That sounds like a nice addition. If I understand correctly: that new operator, let's call that X?, would take two inputs and return the first input if it's not null, and the second otherwise. Correct? I take it that "null" means "falsey"? So for example [0 1]3X? would return 3 because [0 1] is falsey (according to Matlab's if rules), whereas [5 1]3X? would return [5 1].

@RainerP. However, I don't see how that would help in your example, because the condition "first operand positive" is not the same as the first operand being truthy. For an arbitrary condition, the three things would be needed: operand 1, condition, operand 2. Then X? would take operand 1 if condition is truthy, and operand 2 if it's falsey. That would only save the x and the ]. For example: t0>'default'X? would take the top of the stack if positive, or else it would replace it by 'default'. Do you see a way to avoid that t0>?

I think I'm going ahead with removing & and | for the next "release" of the language (sorry for these changes, I'm still refining things). You may want to change & into * in your answer. In fact, I think | would be a nice symbol for the "ternary if" operator I described in my previous comment (take operand 1 or 2 depending on condition being truthy or falsey)

@LuisMendo Yes, that's correct. But I don't think its neccessary if the value  to be preserved is already in a condition where a boolean aperator can evaluate it. Instead of [5 1]3X? we can just use [5 1]?~x3] which is also ok. The main problem I have is that a test like [5 1]0> destroys the original value. I think we should implement X? as if > 0, preserve and Y? as if >= 0, preserve. That allows us to do any of the checks >0, >=0, <0, <=0, the latter two by negating the value on the stack first. Example: i_0Y?_ evaluates to if input <=0, keep it, else replace by 0.

I see two potential problems here. (1) If you negate the value first, you are again destroying it. (2) This wouldn't cover conditions like being empty, being even etc. I think you need to be able to specify the condition. I'm thinking CJam's "ternary if", but with the condition on top, which I think is more useful

Negation doesn't destroy it, it's bijective. But since you have to load the other value negated and then negate it back, it also adds up to the character count.

How about an else-clipboard. A single character operator that copies the top of stack to clipboard that is automatically used (pushed) as else branch of the next if clause that deosn't have an explicit one?

@RainerP. Can you give an example how that else-clipboard would be used? (As for negation being bijective: 5~ gives 0 (or false), and then ~ on that gives 1 (or true), not the original 5)

@LuisMendo 5_ gives -5 on the stack, then we could perform an operation that preserves the value (or not) as we discussed, afterwards another _ gives the original value or the negated default.  The clipboard: let a comparison or other conversion to logical copy their first operand to a clipboard before destroying it (just like the last user input is always in G), so we can use paste it in the conditional branches. Example [5, 1]3>?E}0] where > copies the first operand  (or both) to the clipboard(s) E.

@RainerP. About _: got it. I thought you meant logical negation. Automatic copy of recent function inputs was already added a few days ago. See section 5.4.2 of the specificacion document, clipboard M. But that's not helpful in this case. Copying first operand of a logical operation is indeed useful here, but I'm not sure how useful it would be in general

@RainerP. I think now I understand better what you meant here. Don't you think it would be better to do it as a ternary if? Maybe with the structure "arg1, cond, arg2". It picks arg1 or arg2 depending on cond. Your example "if input <=0, keep it, else replace by 0" would be (spaces added) i t0<~ 0 X?, which is a little longer but more flexible (cond could be "isempty", "isprime" etc). Maybe I could use | (now that it's free) instead of X? to save one byte

@LuisMendo I think the automatic copy on comparison combined with the ternary if is pretty powerful. You could even reuse clipboard M so that it holds last function or comparison input. If you employ such a clipboard, take the condition as first argument of the ternary operator which allows to arrange the two other arguments arbitrarily. Your example becomes i 0< 0 M | or i 0< M 0 | respectively, so we never need to use ~.

@RainerP. Problem is, M holds all inputs to recent functions. Besides, it requires an input number (it would be 1M in this case, 1for most recent function). That's why I think the condition in the middle could be better (then you can use t for arg1), although sometimes requires a ~

Is there another free character we could use for such a feature?

@RainerP. I think I could reuse M for that. 1M...3M (or even 4M) are already defined. I could define 5M for "paste first input of second most recent function", 6M for second input from that function, 7M for first input or most recent function, etc. Something along these lines

ES6, 50 48 bytes
m=>m.map(h=>{f=h>p?c+=!f:f&&h==p;p=h},p=c=f=0)|c

Saved 2 bytes thanks to @user81655.
Ungolfed:
function peaks(mountains) {
    var previous = 0;
    var count = 0;
    var plateau = false;
    for (var height of mountains) {
        if (height > previous) {
            if (!plateau) count++;
            plateau = true;
        } else if (height != previous) {
            plateau = false;
        }
    }
    return count;
}

@user81655 Thanks for drawing my attention to that subtlety. (I've not used .map()| before.)

Jelly, 27 bytes
ṡ2EÐḟFs2ḣ€1S€ṡ3M€Fċ2
0;⁸;0Ç

Try it online!

Jelly without TIO??? lol

This was a long time ago, before I knew how to link to TIO. I'll leave it like this for posterity.

Screw dat I fix

<><><>_<

05AB1E, 9 bytes
Ô0.ø¥0‹ÔO

Try it online!
Explanation:
Ô0.ø¥0‹ÔO      Full program
Ô              Uniquify (= remove plateaus)
 0.ø           Surround with zeros
    ¥          Push deltas
     0‹        Test each element if lower than 0
               --- we now have a list with 0's (= going uphill) and
                   1's (going downhill). Since we removed plateaus, all
                   we have to do now is to count the number of ramps
                   going downhill
       Ô       Uniquify (reduce ramps to length 1)
        O      Total sum of the list

Japt, 14 bytes
iT òÎmÎä> ò> l

Try it (includes all test cases)
Accommodating the empty array cost 2 bytes.
iT òÎmÎä> ò> l     :Implicit input of array
iT                 :Prepend 0
   ò               :Partition between elements where
    Î              :  The sign of their difference is truthy (not 0)
     m             :Map
      Î            :  First element
       ä>          :Consecutive pairs reduced by >
          ò>       :Partition after elements that are greater than the next
             l     :Length

Husk, 11 bytes
#←gẊo±>m←gΘ

Try it online!
#←gẊo±>m←gΘ
#               # how many truthy elements in list of
 ←              # first element of each sublist of
  g             # grouped identical elements of
   Ẋ            # apply to each pair in list
    o±>         # sign of greater than (1 if greater than, 0 otherwise)
       m←       # make list from first element of each sublist of
         g      # grouped identical elements of
          Θ     # input prepended with zero

Ah, yes, The mountain range sequence.

GolfScript, 35
~0+0\{.@=!},+:a,2-,{a\>3<.$2=?1=},,

Test online
Basically removes duplicates, adds a 0 to both ends, and checks how many triples have a maximum in the center.

Java 8, 141 bytes
l->{int r=0,i=1,t;for(l.add(0,0),l.add(0);i<l.size()-1;r+=t>l.get(i-1)&t>l.get(++i)?1:0)for(;(t=l.get(i))==l.get(i+1);)l.remove(i);return r;}

Can probably be golfed by using a different approach, or an array as input instead of List.
Explanation:
Try it here.
l->{                     // Method with ArrayList<Integer> parameter and int return-type
  int r=0,               //  Result-integer
      i=1,               //  Index-integer
      t;                 //  Temp integer
  for(l.add(0,0),        //  Add a 0 at the start of the list
      l.add(0);          //  Add a 0 at the end of the list
      i<l.size()-1;      //  Loop (1) from index 1 through length-1 (0-indexed)
      r+=                //    After every iteration, raise the result-integer by:
         t>l.get(i-1)    //     If the current item is larger than the previous
         &t>l.get(++i)?  //     and larger than the next:
          1              //      Increase `r` by 1
         :               //     Else:
          0)             //      `r` remains the same
    for(;(t=l.get(i))==l.get(i+1);
                         //   Inner loop (2) as long as there are two adjacent equal items
      l.remove(i)        //    And remove one of those two equal integers
    );                   //   End of inner loop (2)
                         //  End of loop (1) (implicit / single-line body)
  return r;              //  Return the result-integer
}                        // End of method

Python 3, 68 bytes
f=lambda a,*b,p=0:(p[*b,0][0])+(len(b)and f(*b,p=[p,a][a!=b[0]]))

Try it online!

><> (Fish), 59 bytes
0i:0(?v:@)$!
v&01~~/
l
1
-
?
\?v  >^&+\
& \:?^v
\n;   \&1/

Try it online! - Animated Version
Explanation

Green: Read the input, push 1 if the value is less than the previous, 0 if it's more. Add a 0 and a 1 to the ends of the stack. Set the register to 0.
Blue: While the stack is not empty, check for a 0 followed by a 1. If so increment the register. In all other cases just pop a value.
Yellow: Print the result when the stack is empty.