3 ms·
It is not sarcasm. Yes, they love working with me, they learn new things from me and they use it. Generally their face is like "o_O I wish I've learned it befor
by darkhorn 8y ago
It is not sarcasm. Yes, they love working with me, they learn new things from me and they use it. Generally their face is like "o_O I wish I've learned it before". I use build-in functions of PHP and Java in way without loops, there is nothing unknown. I don't write Erlang code. Here is an example what I mean;
<?php declare(strict_types=1);
function fibonacci_nth(int $n): int {
if($n === 0) return 0;
if($n === 1) return 1;
else return fibonacci_nth($n - 2) + fibonacci_nth($n - 1);
}
function fibonacci_series(int $n): array {
return array_map('fibonacci_nth', range(0, $n));
}
And here in Python
class Fibonacci:
def fibonacci_nth(self, n):
if(n == 0): return 0
if(n == 1): return 1
else: return self.fibonacci_nth(n-1) + self.fibonacci_nth(n-2)
def fibonacci_series(self, n):
return [self.fibonacci_nth(x) for x in range(n+1)]
- jodrellblank 8y ago"no loops means less bugs" But the loops will be clear and explicit. People can check if you have an off-by-one error. Python does not support many recursive calls, after "n" gets beyond a certain number, the code will crash with a RecursionError. That is a bug which is much harder to see. The code will crash if N < 0 for the n_th() method, which is probably a bug.