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

How to count records of a list with a specific property in OCaml?

$
0
0

Lets say we have a record which defines a person type with the properties name and age:

type person = {name:string ; age:int };;

and initialize a list with different types:

let personlist = [{name="alexander";age=21};{name="benjamin";age=30};{name="claudia";age=21}];;

How can I count the amount of types with a specific age, lets say 21 (alexander and claudia) so that the output in this case would be two?


Viewing all articles
Browse latest Browse all 594

Trending Articles



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