aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/spp/rpp/ratlibr/stake.r
blob: 52a9a096d4f5a09907ed1fb354c256be1d95b11f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
include	defs

# stake --- take characters from a string APL-style

   integer function stake (from, to, chars)
   character from (ARB), to (ARB)
   integer chars

   integer len, start
   integer length, ctoc, max0

   len = length (from)
   if (chars < 0) {
      start = max0 (len + chars, 0)
      return (ctoc (from (start + 1), to, len + 1))
      }
   else
      return (ctoc (from, to, chars + 1))

   end