公理及其图书馆
f(n:PI,a:INT,b:INT):List INT==
r:List INT:=[]
a>b or n>99999999 =>r
d:=1+b-a
for i in 1..n repeat
r:=concat(r,a+random(d)$INT)
r
在f(n,a,b)且a> b的情况下,上面的f()函数将空列表作为错误返回。在其他无效输入的情况下,它不会在Axiom窗口中运行并显示一条错误消息,因为参数将不是正确的类型。例子
(6) -> f(1,1,5)
(6) [2]
Type: List Integer
(7) -> f(1,1,1)
(7) [1]
Type: List Integer
(10) -> f(10,1,1)
(10) [1,1,1,1,1,1,1,1,1,1]
Type: List Integer
(11) -> f(10,-20,-1)
(11) [- 10,- 4,- 18,- 5,- 5,- 11,- 15,- 1,- 20,- 1]
Type: List Integer
(12) -> f(10,-20,-1)
(12) [- 4,- 5,- 3,- 4,- 18,- 1,- 2,- 14,- 19,- 8]
Type: List Integer
(13) -> f(10,-20,-1)
(13) [- 18,- 12,- 12,- 19,- 19,- 15,- 5,- 17,- 19,- 4]
Type: List Integer
(14) -> f(10,-20,-1)
(14) [- 8,- 11,- 20,- 10,- 4,- 8,- 11,- 3,- 10,- 16]
Type: List Integer
(15) -> f(10,9,-1)
(15) []
Type: List Integer
(16) -> f(10,0,100)
(16) [72,83,41,35,27,0,33,18,60,38]
Type: List Integer