Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/line-o/functastic-php

Some experiments with some of the language features of PHP v5.3+
https://github.com/line-o/functastic-php

Last synced: 26 days ago
JSON representation

Some experiments with some of the language features of PHP v5.3+

Awesome Lists containing this project

README

        

#Functional Programming in PHP

![test](http://4.bp.blogspot.com/_6m1GwPz8e34/S6LaIgiBs0I/AAAAAAAAASw/66RPdKfgnfo/s200/functionalProgramming.png)

##What is Functional Programming all about
- (un)typed lambda calculus
- type theory
- type inference (Hindley-Milner)
- intuitionistic types(?)
- predicate logic
- mathematical proofs

* Don't *really* know what all this is?
* Me neither, but we may find out.

##the Idea behind it

* no side effects
* no state

## Lambda functions

````php
0 ? 'true' : 'false');
}
return array_map('greaterThanZero', array(0, 1))
}
print_r(do());
````

* introduces a new global function
* name collisions

after:
````php
0 ? 'true' : 'false');
};
return array_map($map_func, array(0, 1));
}
print_r(do());
````

* anonymous (lambda) function
* exists only in local scope

### Scope?

````php
$i) };
print("#<$i: " . count(array_filter($map_func, $rng)) . PHP_EOL);
}
````

## Currying / Partial Application

specific example:
````php
Juri Leino
working @spot-media