blob: f700aadc50ea0381ae887e35be106e33cdd96f3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
^++=t/wo
c/ount elements on the stack but more complicated / end [... elem] start -- end [... elem] count
{
+ / increment counter
%t / get last elem
E? / if it's end then stop counting
%t / reverse back
#
;
&e=e / pop elem saving
@c / end [...] start+1
$e%t / reverse back
}
C/ount elements on the stack / [elem ...] -- [elem ...] elem-count
{
$E / push end on the stack
%_ / reverse the stack
^- @c / count elements
&c=c / save count
%_ / reverse back
=_ / get rid of end
$c / push count back
}
^-=E / end of count
^^^^^
@C
|