-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOMB.lss
57 lines (51 loc) · 1.57 KB
/
COMB.lss
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<h1>COMB - Number of combinations</h1>
[[COMB(N,M)]] returns the number of combinations of [[N]] things,
taken [[M]] at a time.
<h2>Uses</h2>
<<INCLUDES>>=
@
<<COMB>>=
-PUBLIC COMB()
*
DEFINE('COMB(N,M)') :(COMB_END)
*
COMB COMB = EQ(M, 0) 1 :S(RETURN)
COMB = COMB(N - 1, M - 1) * N / M :(RETURN)
*
COMB_END
@
<<unit_test>>=
#!/usr/bin/bash
exec "snobol4" "-b" "$0" "$@"
-INCLUDE 'COMB.INC'
&CODE = 1
&CODE = 0
END
@
<<>>=
-MODULE COMB
<<INCLUDES>>
-IN72
-STITL COMB
-EJECT
*
************************************************************************
* *
* ##### ####### # # ###### *
* # # # # ## ## # # *
* # # # # # # # # # *
* # # # # # # ###### *
* # # # # # # # *
* # # # # # # # # *
* ##### ####### # # ###### *
* *
* COMB COMBINATIONS *
* *
************************************************************************
*
* COMB.lss
*
<<COMB>>
*
* CE: .MSNOBOL4;
@