From: Daniel Carrera Date: 2003-02-07T04:44:30+09:00 Subject: Re: Returning a class. > ----- Original Message ----- > Is it possible to generate a class at run-time and return it? > ---------------------------- > > Not exactly sure what you are looking for, but maybe this will help you? If > not, could you give a little more information about what you want your > auto-generated class to look like? What you wrote helps, I think. I'll try to implement it. But to answer your question, this is what I want: I put together a Polynomial class. You can use it like this: $ irb >> require 'poly' => true >> include Math::Polynomial => Object >> puts 7 * X**3 + 4 * X**2 - 14 * X**3 - 5 * X **17 - 23 17 3 2 - 5 X - 7 X + 4 X - 23 => nil >> puts (X - 1) * (X + 1) 2 X - 1 => nil >> After I've done some more work, I'd like to extend this so that it works over any ring (not just real numbers). I think that it would be neat. I also thought that I could make a Frac() class that gives you the fraction field of a ring (class). For instance, Frac(Integer) would be the same thing as Rational. If I define a similar Polynomial, I could use Frac(Polynomial(Integer)) to define a class whose elements are of form p(x)/q(x) I don't know how I would do this. I was just investigating the possibility. -- Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137