Searching for OCaml Lists

Asked 1 years ago, Updated 1 years ago, 93 views

lets=[1;2;3];[4;5;6];[7;8;9];

What should I do if I want a list of int lists with specific values?

ocaml

2022-09-30 14:04

1 Answers

You can use the filter function to extract only the elements that meet the conditions of the functions in List module and the exists function to see if there is at least one element that meets the condition:

 (Example of looking for a list containing *5)
# List.(filter(funx->exists(funx->x=5)l)ls);;


2022-09-30 14:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.