Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 595

OCaml find number of times n is present in list

$
0
0

I am a beginner with OCmal. I have a list named l and a number stored in N.I need to find the number of times N repeats in l.

let l = [1;2;3;4;5;6;7;1;9;10;11];;let n = 1;;

I want to write a function which tells that number of times n is present in l.

I started like this but I am blocked:

for i = 0 to (List.length l) do(* codes here: i want to find that the value of N is present twice in the list *)done;;

Viewing all articles
Browse latest Browse all 595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>