1; SketchyLISP Library
2; Copyright (C) 2005,2006,2007 Nils M Holm. All rights reserved.
3; See the file LICENSE of the SketchyLISP distribution
4; for conditions of use.
5
6; ---name---
7; succ
8
9; ---conformance---
10; SketchyLISP Core
11
12; ---purpose---
13; Find the successor of a decimal digit.
14; .B
15; .C (succ 9d) => ().
16
17; ---args---
18; X - symbol representing a digit
19
20; ---keywords---
21; SUCC function, successor, numbers, digits
22
23; ---see-also---
24; digits, pred
25
26; ---example---
27; (succ 3d) => 4d
28
29(require "digits.scm") ; 0d 1d 2d 3d 4d 5d 6d 7d 8d 9d
30
31; ---code---
32(define (succ x)
33  (cond ((eq? x 0d) 1d)
34        ((eq? x 1d) 2d)
35        ((eq? x 2d) 3d)
36        ((eq? x 3d) 4d)
37        ((eq? x 4d) 5d)
38        ((eq? x 5d) 6d)
39        ((eq? x 6d) 7d)
40        ((eq? x 7d) 8d)
41        ((eq? x 8d) 9d)
42        ((eq? x 9d) '())
43        (else (bottom 'digit 'expected))))
44