John Fredsted

2253 Reputation

15 Badges

20 years, 193 days

MaplePrimes Activity


These are replies submitted by John Fredsted

Thanks for this insight into the structure of MapleSoft. I can only agree with you on the last sentence of yours.

I would say that the question would naturally belong to a new thread as I think this thread is about how to create objects, as the name of the thread correctly indicates.

Anyway, concerning your question: From the information you provide, it is hard to tell exactly what is going on, so could you provide some of the code itself, or, alternatively, upload your worksheet?

I would say that the question would naturally belong to a new thread as I think this thread is about how to create objects, as the name of the thread correctly indicates.

Anyway, concerning your question: From the information you provide, it is hard to tell exactly what is going on, so could you provide some of the code itself, or, alternatively, upload your worksheet?

Using keyword parameters, see the help page ?parameter_classes, you could write the rectangle constructor as follows:

makeRectangle := proc({l := L,h := H})
   module()
      export getLength,getHeight,findArea;
      getLength := () -> l;
      getHeight := () -> h;
      findArea  := () -> l * h;
   end module
end proc:

which makes possible the following:

rect1 := makeRectangle():
rect2 := makeRectangle(l = 10):
rect3 := makeRectangle(h = 20):
rect4 := makeRectangle(l = 10,h = 20):
rect5 := makeRectangle(h = 20,l = 10):
rect1:-getLength(),rect1:-getHeight(),rect1:-findArea();
rect2:-getLength(),rect2:-getHeight(),rect2:-findArea();
rect3:-getLength(),rect3:-getHeight(),rect3:-findArea();
rect4:-getLength(),rect4:-getHeight(),rect4:-findArea();
rect5:-getLength(),rect5:-getHeight(),rect5:-findArea();
                                  L, H, L H
                                 10, H, 10 H
                                 L, 20, 20 L
                                 10, 20, 200
                                 10, 20, 200

Using keyword parameters, see the help page ?parameter_classes, you could write the rectangle constructor as follows:

makeRectangle := proc({l := L,h := H})
   module()
      export getLength,getHeight,findArea;
      getLength := () -> l;
      getHeight := () -> h;
      findArea  := () -> l * h;
   end module
end proc:

which makes possible the following:

rect1 := makeRectangle():
rect2 := makeRectangle(l = 10):
rect3 := makeRectangle(h = 20):
rect4 := makeRectangle(l = 10,h = 20):
rect5 := makeRectangle(h = 20,l = 10):
rect1:-getLength(),rect1:-getHeight(),rect1:-findArea();
rect2:-getLength(),rect2:-getHeight(),rect2:-findArea();
rect3:-getLength(),rect3:-getHeight(),rect3:-findArea();
rect4:-getLength(),rect4:-getHeight(),rect4:-findArea();
rect5:-getLength(),rect5:-getHeight(),rect5:-findArea();
                                  L, H, L H
                                 10, H, 10 H
                                 L, 20, 20 L
                                 10, 20, 200
                                 10, 20, 200

That is quite all right. I, too, can get carried away in excitement.

That is quite all right. I, too, can get carried away in excitement.

Maybe I misunderstand what you mean, but the second part of my previous post, using the procedure makeRectangle, which is a socalled object constructor, can be used for creating different rectangle objects, as are rectangle1 and rectangle2.

I use tabbing to indent my code. However, as I have reported elsewhere, although it works flawlessly in Maple 9.5, it works only erratically in Maple 11. Instead of tabbing, though, you can indent using a certain number of spaces, but that, unfortunately, becomes cumbersome for highly indented code. To have my code, with indentation, nicely formatted on the screen I surround the code with <pre> ... </pre>.

Maybe I misunderstand what you mean, but the second part of my previous post, using the procedure makeRectangle, which is a socalled object constructor, can be used for creating different rectangle objects, as are rectangle1 and rectangle2.

I use tabbing to indent my code. However, as I have reported elsewhere, although it works flawlessly in Maple 9.5, it works only erratically in Maple 11. Instead of tabbing, though, you can indent using a certain number of spaces, but that, unfortunately, becomes cumbersome for highly indented code. To have my code, with indentation, nicely formatted on the screen I surround the code with <pre> ... </pre>.

Thanks for explaining better than I did what is going on.

And thanks for providing a nice trick, different from the conversion to a polynomial, for removing the non-polynomial last term: it would never have dawned on me that something like eval(...,O = 0) could be used for removing that term. But, of course, looking a bit into the matters, it works because the operands of the Taylor series contains O(1) explicitly.

Thanks for explaining better than I did what is going on.

And thanks for providing a nice trick, different from the conversion to a polynomial, for removing the non-polynomial last term: it would never have dawned on me that something like eval(...,O = 0) could be used for removing that term. But, of course, looking a bit into the matters, it works because the operands of the Taylor series contains O(1) explicitly.

It is comforting to read that "He is also mystified by the "fact" that the market seemed to prefer a product that looked good over a product that was correct."

In my opinion this state of affairs holds also today, probably even stronger. I guess that that is what happens with every company that becomes owned by stockholders. In this respect the following excerpt from

http://mathworld.wolfram.com/about/erics_commentary.html,

in which  Eric W. Weisstein comments on the lawsuit served on him and Wolfram Research in the spring of 2000 by CRC Press LLC, is highly interesting, I think:

I have come to realize how unusual it is to be working for a company that is run by people who still enjoy the core activities for which the company was founded. Very early in the lawsuit, a Wolfram Research response to the lawsuit mentioned that Wolfram Research has chosen to remain privately held in order to be free from the obligation to outside stockholders, who appear so often to focus corporations inordinately on short-term financial results. Wolfram Research's principals believe that they can take the long and broad view of the corporation's mission, as they could not if they had to satisfy stock analysts and uninvolved stockholders.

In our world in which consumers seem to become ever more desperately dependent upon shallow gadgets and accessories this depressing state of affairs seems unavoidable, I think, and probably will only become worse in the future - if not instead the global economy collapses as a direct consequence of the fact that the (completely mad) paradigm of sustained economical growth is fundamentally inconsistent with our planet being a materially finite system.

But I am being lead astray. Back to the beautiful world of mathematics and theoretical physics ...

Compare my posts The same here and No return to old editor above.

So basically what you are saying is that the update of mapleprimes has made the only two now available editors less suitable for editing posts than was the old editor. That is actually quite depressing.

I have experienced the same thing. At this very moment of writing I am looking at the new editor even though for a short period of time (yesterday, I believe) I had an editor with no buttons whatsoever.

That being said, I am certainly not enthusiastic about such an editor with no buttons at all: I assumed that turning off the new editor meant turning on the old editor where there were useful buttons for bold, italic, and code.

First 41 42 43 44 45 46 47 Last Page 43 of 68