Created
May 8, 2019 05:18
-
-
Save datashaman/ae9623382e62477ac72da314e9294fc3 to your computer and use it in GitHub Desktop.
Datashaman\Logic\D Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<<<CONFIG | |
packages: | |
- "datashaman/logic: dev-master" | |
CONFIG; | |
# | |
# This is a Melody script. http://melody.sensiolabs.org/ | |
# | |
use function Datashaman\Logic\D; | |
use function Datashaman\Logic\mkMaybe; | |
$f = D(0); | |
echo $f(mkMaybe(null)) . PHP_EOL; | |
echo $f(mkMaybe(12)) . PHP_EOL; | |
$f = D(0, function ($value) { | |
return $value * 2; | |
}); | |
echo $f(mkMaybe(null)) . PHP_EOL; | |
echo $f(mkMaybe(12)) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment