Skip to content

Instantly share code, notes, and snippets.

View sergiors's full-sized avatar
🎯
Focusing

Sérgio R Siqueira sergiors

🎯
Focusing
View GitHub Profile
@sergiors
sergiors / 2x1.gif
Last active April 11, 2019 13:53
Test
2x1.gif
@sergiors
sergiors / 1x2.gif
Last active April 11, 2019 03:30
is
1x2.gif
@sergiors
sergiors / 1x1.gif
Last active April 11, 2019 03:29
What
1x1.gif
def path(dct: dict, paths: list):
k = paths[0]
v = dct.get(k, None)
return v if type(v) is not dict else path(v, paths[1:])
# or
def path(dct: dict, paths: list):
k = paths[0]
type(1) // => int
type(1.1) // => float
type('hello') // => string
type([1, 2, 3, 4]) // => array
type({true: 1, false: 0}) // => hashmap
type(?) // => null
// class
User {
str name, [str, ?] lastname
<?php
abstract class Container extends \Xtreamwayz\Pimple\Container
{
public function __construct(array $values = [])
{
parent::__construct($values));
$this->initializeProviders();
}
@sergiors
sergiors / foldl.php
Last active December 25, 2017 23:51
<?php
// [a] -> a
function head(array $list)
{
return array_slice($list, 0, 1)[0];
}
// [a] -> a
function last(array $list)
@sergiors
sergiors / fp.php
Last active January 12, 2017 12:01
<?php
declare(strict_types = 1);
function id($x)
{
return $x;
}
function anyPass(array $preds)
<?php
function head($str)
{
return substr($str, 0, 1);
}
function last($str)
{
return substr($str, -1);
<?php
use const Prelude\{_, id, isResource};
use function Prelude\{always, ifElse, apply, placeholder};
class Stream
{
protected $stream;
public function __construct($stream, $options = [])