Ocaml: function cannot return complete resulting list

Jackie19

I am working on the question from this site, one of the question is asking to return Goldbach conjecture in a given range.

My answer works fine for small ranges, but for large range (e.g. 2 - 2000), it only return part of the solution like the following:

[(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, ...)); ...]

I tried to use the solution provided by the website, but same thing happens. I wonder if there is a way to return the complete list of solutions.

Thanks!

Jeffrey Scofield

I think you mean that the toplevel is only showing a prefix of the list. You can solve this by writing your own code to show the list.

Something like this would work:

let p (a, (b, c)) = Printf.printf "(%d, (%d, %d))\n" a b c

let printMyList l = List.iter p l

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Decrypting return of function in OCaml

From Dev

OCaml function to return a list of tuples whose last element matches a predicate

From Dev

ocaml function asks me to return unit instead of 'a list

From Dev

How to specify a function parameter and return type as a List in ocaml?

From Dev

OCaml This is not a function; it cannot be applied

From Dev

OCaml This is not a function; it cannot be applied

From Dev

C linkage function cannot return C++ class - error resulting from the contents of my method

From Dev

C linkage function cannot return C++ class - error resulting from the contents of my method

From Dev

ocaml 'a list list function tuples

From Dev

How to return void in a function in OCaml?

From Dev

OCaml function: replace a element in a list

From Dev

Return the middle value from list in OCaml

From Dev

Return num instead of int in an OCaml Function

From Dev

function without args and return type in OCaml

From Dev

Sorting List with OCaml standard library function

From Dev

OCaml - a function which returns all the prefixes of a list

From Dev

OCaml - function calling for each element in a list

From Dev

function returns list in reverse order in OCaml

From Dev

OCaml - How do I return list of lists from a list?

From Dev

Using fold to check if a list is divisible by an int and return bool list ocaml

From Dev

Difference between List.iter and List.map function in OCaml

From Dev

Cannot return equation from function

From Dev

Cannot return equation from function

From Dev

How to find duplicates in a std::vector<strings> and return a std::list of them sorted alphabetically without duplicates in that resulting list

From Dev

cannot convert void to list, return a sorted list

From Dev

How do I write a function to create a circular version of a list in OCaml?

From Dev

In OCaml, why is there an auxiliary function in Core's List.find?

From Dev

OCaml - Creating a function which prompts for floats and returns a list of floats

From Dev

Python: Return function won’t return a list

Related Related

  1. 1

    Decrypting return of function in OCaml

  2. 2

    OCaml function to return a list of tuples whose last element matches a predicate

  3. 3

    ocaml function asks me to return unit instead of 'a list

  4. 4

    How to specify a function parameter and return type as a List in ocaml?

  5. 5

    OCaml This is not a function; it cannot be applied

  6. 6

    OCaml This is not a function; it cannot be applied

  7. 7

    C linkage function cannot return C++ class - error resulting from the contents of my method

  8. 8

    C linkage function cannot return C++ class - error resulting from the contents of my method

  9. 9

    ocaml 'a list list function tuples

  10. 10

    How to return void in a function in OCaml?

  11. 11

    OCaml function: replace a element in a list

  12. 12

    Return the middle value from list in OCaml

  13. 13

    Return num instead of int in an OCaml Function

  14. 14

    function without args and return type in OCaml

  15. 15

    Sorting List with OCaml standard library function

  16. 16

    OCaml - a function which returns all the prefixes of a list

  17. 17

    OCaml - function calling for each element in a list

  18. 18

    function returns list in reverse order in OCaml

  19. 19

    OCaml - How do I return list of lists from a list?

  20. 20

    Using fold to check if a list is divisible by an int and return bool list ocaml

  21. 21

    Difference between List.iter and List.map function in OCaml

  22. 22

    Cannot return equation from function

  23. 23

    Cannot return equation from function

  24. 24

    How to find duplicates in a std::vector<strings> and return a std::list of them sorted alphabetically without duplicates in that resulting list

  25. 25

    cannot convert void to list, return a sorted list

  26. 26

    How do I write a function to create a circular version of a list in OCaml?

  27. 27

    In OCaml, why is there an auxiliary function in Core's List.find?

  28. 28

    OCaml - Creating a function which prompts for floats and returns a list of floats

  29. 29

    Python: Return function won’t return a list

HotTag

Archive