我正在研究这个site的问题,其中一个问题是要求在给定范围内返回哥德巴赫猜想。
我的答案适用于小范围,但对于大范围(例如2 - 2000),它只返回部分解决方案,如下所示:
[(2, (2, 0)); (4, (2, 2)); (6, (3, 3)); (8, (3, 5)); (10, (3, 7));
(12, (5, 7)); (14, (3, 11)); (16, (3, 13)); (18, (5, 13)); (20, (3, 17));
(22, (3, 19)); (24, (5, 19)); (26, (3, 23)); (28, (5, 23)); (30, (7, 23));
(32, (3, 29)); (34, (3, 31)); (36, (5, 31)); (38, (7, 31)); (40, (3, 37));
(42, (5, 37)); (44, (3, 41)); (46, (3, 43)); (48, (5, 43)); (50, (3, 47));
(52, (5, 47)); (54, (7, 47)); (56, (3, 53)); (58, (5, 53)); (60, (7, 53));
(62, (3, 59)); (64, (3, 61)); (66, (5, 61)); (68, (7, 61)); (70, (3, 67));
(72, (5, 67)); (74, (3, 71)); (76, (3, 73)); (78, (5, 73)); (80, (7, 73));
(82, (3, 79)); (84, (5, 79)); (86, (3, 83)); (88, (5, 83)); (90, (7, 83));
(92, (3, 89)); (94, (5, 89)); (96, (7, 89)); (98, (9, 89)); (100, (3, 97));
(102, (5, 97)); (104, (3, 101)); (106, (3, 103)); (108, (5, 103));
(110, (3, 107)); (112, (3, 109)); (114, (5, 109)); (116, (3, 113));
(118, (5, 113)); (120, (7, ...)); ...]
我尝试使用网站提供的解决方案,但同样的事情发生了。我想知道是否有办法返回完整的解决方案列表。
谢谢!
答案 0 :(得分:5)
我认为你的意思是toplevel只显示列表的前缀。您可以通过编写自己的代码来显示列表来解决此问题。
这样的事情会起作用:
let p (a, (b, c)) = Printf.printf "(%d, (%d, %d))\n" a b c
let printMyList l = List.iter p l
答案 1 :(得分:3)
这是因为顶层没有显示太长的值。您可以使用pragma:
更改此长度#print_length n;;
另一种解决方案,也许更好,就是编写自己的打印功能。 ;)