Functional Programming with Phel ๐Ÿ˜

When PHP meets FP ๐Ÿš€๐Ÿš€๐Ÿš€๐ŸŒš

What is Functional Programming?

Imperative vs Declarative

n! = n * (n - 1) * (n - 2) * ... * 1
5! = 5 * 4 * 3 * 2 * 1
5! = 5 * 4!

Imperative programming

function factorial(int $number): int
{
$factorial = 1;
while ($number >= 1) {
$factorial *= $number;
$number--;
}
return $factorial;
}

Declarative programming

(defn factorial
[number]
(if (<= number 1)
1
(* number (factorial (- number 1)))))

Conclusion

https://phel-lang.org/

Competitive, entrepreneur and autodidact. Hard worker, lover of technology and free software.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store