mercredi 20 juillet 2016

Does a programming language with the following features exist?

Is there a language which will support the following concept or is there a pattern to achieve something similar with existing one?

Concept

I want to define a Square with the following properties: Length, Height, Area, Perimeter; where Area = Length * Height and Perimeter = (2 * Length) + (2 * Height).

Given the statement above, if I want to create a square by giving it a Length and a Height, it should of course automatically fill out the rest of the properties.

However, it should go further and automatically allow you to create a Square with any two properties (say Height and Perimeter) because that is also mathematically enough to create the same Square.

Aucun commentaire:

Enregistrer un commentaire