<?php

/* 
 * Przykładowy kod do książki: Algorytmy i struktury danych w języku PHP 7
 * 
 * Autor: Mizanur Rahman <mizanur.rahman@gmail.com>
 * 
 */

require __DIR__ . '/vendor/autoload.php';

use Tarsana\Functional as F;

$stack = [];

$push = F\append(F\__(), F\__());
$top = F\last(F\__());
$pop = F\init(F\__());

$stack = $push(1, $stack);
$stack = $push(2, $stack);
$stack = $push(3, $stack);

echo "Stos to: ".F\toString($stack)."\n";

$item = $top($stack);
$stack = $pop($stack);

echo "Zdjęty element: ".$item."\n";
echo "Stos to: ".F\toString($stack)."\n";

$stack = $push(4, $stack);

echo "Stos to: ".F\toString($stack)."\n";