Classification of numbers using metaprogramming

I am trying to classify a large set of floating-point numbers in various range and count them. I want to divide them into a large no of classes. Practically it is impossible to write every clause using an if-else kind of statement. How can one use metaprogramming to tackle this kind of situation?

Based on your description, I don’t think you need metaprogramming. A for loop witch checks some conditions should do fine?


Actually I want to classify them in 1000+ no of clases and do different operation for each clases, also the range of the each clases is not same.

That still sounds like it’s doable with nested loops. Operators and functions are first class, you can thus loop over functions, “class conditions” and lastly, your numbers.

1 Like

Definately I will try that and thanks for your cooperation.

1 Like