Idiomatic?

which is more idiomatic? amazing how similar ruby and python are.

and what does the guy mean with “pure” here:
http://www.linuxjournal.com/article/4834
that it is purely OO and consequent? Would Python be impure in his
meaning of pure?

def fib(n, a=0, b=1)
if n > 0
then fib(n-1, a+b, a)
else a
end
end

def fibo(n)
a, b = 0, 1
while n > 0
a, b, n = a+b, a, n-1
end
a
end

def fac(n, acc=1)
if n > 0
then fac(n-1, n*acc)
else acc
end
end

def fac2(n)
acc = 1
for x in 1…n+1
acc *= x
end
return acc
end

Not sure what you mean, but one small example is that in Python, you
have to do:

len(array)
string.upper(“foo”)

whereas in Ruby you do

array.length
“foo”.upcase

The latter is pure OO, the former is not. This is possible because
everything in Ruby is an object.

cnb [email protected] writes:

which is more idiomatic? amazing how similar ruby and python are.

and what does the guy mean with “pure” here:
Ruby | Linux Journal
that it is purely OO and consequent?

I’m not him, but luckily I don’t have to guess. It’s in the article:

“Everything, including primitive data types like strings and integers,
is represented as an object. Even constants and classes are represented
as objects. This makes Ruby a pure object-oriented language.”

Would Python be impure in his
meaning of pure?

I have only minimal knowledge of Python, but IIRC, python is not as
object-oriented as Ruby is.

def fib(n, a=0, b=1)
if n > 0
then fib(n-1, a+b, a)
else a
end
end

[snip]

What do these have to do with anything?