Count how many times numbers from a list occur in a list of tupled intervals in Scala

Count how many times numbers from a list occur in a list of tupled intervals in Scala

Say I have a list of tuples:

Say I have a list of tuples:

 val ranges= List((1,4), (5,8), (9,10))

and a list of numbers

val nums = List(2,2,3,7,8,9)

I want to make a map from tuple in ranges to how many times a given number from nums fall into the interval of that tuple.

Output:

Map ((1,4) -> 3, (5,8) -> 2, (9,10) -> 1)

What is the best way to go about it in Scala

I have been trying to use for loops and keeping a counter but am falling short. Any help would be very much appreciated.

Best Regards

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Java and Scala: Why Should You Learn Scala?

Java is a general purpose object oriented language. Scala is less readable due to nested code. The process of compiling source code into byte code is slow. ... Scala treated everything as an instance of the class and it is more object oriented language as compare to Java.

The Scala Chronicles: The Beginning

The Scala Chronicles: The Beginning

What I Did Not Know About Scala And Its Standard Library

I am working with Scala as my main programming language for about three years now. I recently went through some basic&nbsp;<a href="https://www.scala-exercises.org/std_lib" target="_blank">Scala language exercises</a>&nbsp;for fun and discovered some features and possibilities I did not know about.