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 | |
class CouldNotForkException extends Exception {} | |
class Fork | |
{ | |
private $task; | |
public function __construct(Closure $task) | |
{ |
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
; The list datatype in scheme is awesome... They are actually nested pairs | |
; so they can be manipulated using the three functions used with pairs. | |
; | |
; - cons: create a pair | |
; - car: return the left side of a pair | |
; - cdr: return the right side of a pair | |
; | |
; This is a fantastic abstraction layer, that can be used to create all other | |
; list functions out there. Some examples: |
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
; Simple fixed point combinator. It's basic, but it does the job... | |
(define (fix function) | |
(lambda args | |
(apply function (cons function args)))) | |
(define factorial | |
(fix | |
(lambda (f x) | |
(if (< x 2) |
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 | |
function within($topic, ...$features) | |
{ | |
return function($do = 'getFailedAssertions') use ($topic, $features) { | |
if ($do === 'getName') { | |
return $topic; | |
} elseif ($do === 'getFailedAssertions') { | |
return array_reduce( | |
$features, |
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
; As seen in my previous gist about lisp list-functions | |
; (https://gist.github.com/turanct/e84be7f355e255c2c1b5) | |
; all list functions can be created relatively easy from | |
; a few function calls, using recursive functions. | |
; As the pattern for those functions is almost always the same, | |
; that can be abstracted out. The way we do this is using folds. | |
; | |
; Folds take a function, an initial value (or carry), and a | |
; list, and they use the function to combine the carry with the | |
; next element of the list. When the fold iterated over the |
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 | |
function partial($function, ...$arguments) | |
{ | |
return function() use ($function, $arguments) { | |
$fullArguments = array_merge($arguments, func_get_args()); | |
return call_user_func_array($function, $fullArguments); | |
}; | |
} |
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 | |
require_once __DIR__ . '/util.php'; | |
require_once __DIR__ . '/wordcount.php'; | |
/** | |
* Create a document, containing 100 pages of 1000 times "foo bar baz qux" | |
*/ | |
$page = str_repeat("foo bar baz qux\n", 1000); | |
$document = array_fill(0, 100, $page); |
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
(use-modules (srfi srfi-1) (ice-9 threads)) | |
;; some funtions to generate page content | |
(define page-contents (list "foo" "bar" "baz" "qux")) | |
(define generate-page | |
(lambda (contents times) | |
(cond | |
((eq? 0 times) '()) | |
(else (append contents (generate-page contents (- times 1))))))) |
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
/tc 00:00:14:00 00:00:17:11 | |
De Amerikaanse overheid | |
bedreigde Zweden met ernstige maatregelen. | |
/tc 00:00:17:16 00:00:20:06 | |
-tenzij file sharing sites, zoals | |
de Pirate Bay, neergehaald werden. | |
/tc 00:00:23:13 00:00:28:04 | |
De rechtszaak tegen de oprichters van |
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
import Shop | |
main = do | |
contents <- getContents | |
let | |
inventory1 = inventoryFromFile contents | |
shop1 = Shop "Simon Says" inventory1 | |
putStrLn $ show shop1 |
OlderNewer