# Declarative Programming Hides Process, Reveals Relationships

`-- zipfibs = 0 : 1 : zipWith (+) fibs (tail fibs)-- recursivefib :: Int -> Intfib 0 = 0fib 1 = 1fib n = fib (n-1) + fib (n-2)n = 37main = do    print "zip lists"    print (fibs !! n)    print (fibs !! (n+1))    print (fibs !! (n+2))    print (fibs !! 2000)    print ""    print "recursive"    print (fib n)    print (fib (n + 1))    print (fib (n + 2))-- edited Nov 2018`

So the infinite list of Fibonacci numbers can be calculated by prepending the elements 1 and `1` to the result of zipping the infinite list of Fibonacci numbers with the tail of the infinite list of Fibonacci numbers using the `+` operator.

`#include <stdio.h>int fibonacci(n){    int a = 1;    int b = 1;    int i;    int tmp;    for(i = 0; i < n - 1; ++i){        // swap a and b        tmp = a;        a = b;        b = tmp;        // add a and b        a = b + a;   }   return a;}int main(){    printf("\nfibonacci(0) = %d", fibonacci(0));    printf("\nfibonacci(1) = %d", fibonacci(1));    printf("\nfibonacci(2) = %d", fibonacci(2));    printf("\nfibonacci(3) = %d", fibonacci(3));    printf("\nfibonacci(4) = %d", fibonacci(4));    printf("\nfibonacci(5) = %d", fibonacci(5));    printf("\nfibonacci(6) = %d", fibonacci(6));    printf("\nfibonacci(10) = %d", fibonacci(10));    printf("\nfibonacci(20) = %d", fibonacci(20));    printf("\nfibonacci(40) = %d", fibonacci(40));    printf("\nfibonacci(50) = %d", fibonacci(50));    printf("\nfibonacci(100) = %d", fibonacci(100));    printf("\ndone");    printf("\n");    return 0;}`

# Declarative Programming is Great For Common Tasks Where You Need Help With The Details

`Point originOne = new Point(23, 94);Rectangle rectOne = new Rectangle(originOne, 100, 200);Rectangle rectTwo = new Rectangle(50, 100);`

# Final Thought: Procedural Programming Gives You More Control, But Is it Worth It?

--

--

## More from HackerNoon.com

Elijah McClain, George Floyd, Eric Garner, Breonna Taylor, Ahmaud Arbery, Michael Brown, Oscar Grant, Atatiana Jefferson, Tamir Rice, Bettie Jones, Botham Jean