Why not Python? (No, no, I am not a spy)

Jeff W. wrote:

return 1 if x <= 1

x * factorial( x - 1 )
end

tail-recursive:

def factorial( x, sum = 1 )
return 1 if x < 1

return sum if x <= 1

factorial( ( x - 1 ), ( sum * x ) )
end

iterative:

def factorial( x )
sum = 1
for i in (1…x).to_a

for i in 1…x

sum *= i
end
end

And why do you call your products “sum”?

Jeff W. [email protected] writes:

ah, but to me that isn’t completely iterative… iterative is using a loop
within a function to make sure it and all functions it calls do not call
back up the tree…

There are no loops in Scheme. (while is syntactic sugar.)

Hi –

On Fri, 23 Dec 2005, Gene T. wrote:

[email protected] wrote:

Oh, let’s :slight_smile: I really wish :: as a synonym for the dot would
disappear. I’ve never understood what purpose is served by it.

if “::” is used exclusively for class constants, i guess it’s slightly
useful, otherwise i tend to agree

For constant lookup it seems perfectly fine. I just don’t know what
it’s doing also being a dot synonym.

David


David A. Black
[email protected]

“Ruby for Rails”, from Manning Publications, coming April 2006!

In message [email protected], Steve L.
[email protected] writes

If you read between the lines in this thread, you notice that only
Python and Ruby are mentioned in positive light. Nobody stood up
for Perl, or VB, or Pascal, or C++, or Java.

OK then. I will. C++ is fantastic. Most likely for jobs you would not or
could not use Ruby for. The products I work on require C++/C and
assembler. You couldn’t possibly write them in Ruby. Even if you could
they would be too slow.

When I’m not using C++, Ruby is what I am using, or intending to use.

Java - I always felt like I was writing code whilst wearing a straight
jacket. In 9 years of using Java (I started in May 1996) I didn’t like
it - but you use what you are asked to use by the customer.

Merry Christmas

Stephen