samedi 10 février 2018

How to store different types in a list?

I'm trying to create a testing framework for my homework assignment. The idea is to pass a list of tests (each of them consists of a function, parameters and and an expected value) to a function that will do the testing and then print a symbol that represents success, failure or an error (exception raised).

The problem is that functions as well as paramters may have different types like int * int -> int or string list -> bool. I store them in tuples but I can't put them in a list since they have different types.

One way to do this is to create a datatype that will have a constructor for each case but it's tedious. So my question is there a simple way to do this?

Aucun commentaire:

Enregistrer un commentaire