On 5/10/06, Dan Shafer <dan@shafermedia.com> wrote:
Well, your result is nothing like I ended up with; you found a much
more elegant solution (iterating over the exp for example). But note
that to create that code I'd have to know about the class String,
streams, collect: (a powerful but really new concept) and the
raisedTo: method. Not hard stuff, of course, but, as you properly
say, it's a question of familiarity and only that.

In Basic, it's something like:

repeat with i = 1 to 10
   print i; i*i, i*i*i
end repeat

You can pretty much write the same in Squeak too:

1 to: 10 do: [:i |
    Transcript
        show: i; tab;
        show: i * i; tab;
        show: i * i * i; cr].

Actually, there's a squared method, but unfortunately, there's no cubed method ;-(

Also, it might be nice if Transcript

Essentially the same in Pascal. But note that the "print" statement
just prints stuff in a predictable place. When I solved the problem
in Smalltalk, I ended up believing that I needed to use the
Transcript for output, which involved figuring out how to get one to
open and print stuff.

I see what you're trying to get at, but unfortunately, this is not a particular good example, because It's the same in other languages too.

I don't know Pascal/Basic, but if you were to do it in Java, or C#, you'll end up using the StringBuilder class, which is just the equivalent to the Stream here. In C#, StringBuilder is part of System.Text, which requires a 'using' statement, so it's not a module that can be used out of the box either (and I'm sure the same is true in the Java case).

Duncan.