This file contains hidden or 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 Text.ParserCombinators.Parsec | |
data Query = And Query Query | |
| Or Query Query | |
| Not Query | |
| Statement String deriving (Show) | |
andParser = do | |
arg1 <- statementParser | |
string " AND " |
This file contains hidden or 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 |
This file contains hidden or 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
#!/usr/bin/env guile -s | |
!# | |
(use-modules | |
(srfi srfi-1) | |
(ice-9 rdelim)) | |
(define words-path "words.txt") | |
(define random-word-from-file |
This file contains hidden or 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
(define create-coord | |
(lambda (x y) | |
(list x y))) | |
(define get-x | |
(lambda (coord) | |
(car coord))) | |
(define get-y | |
(lambda (coord) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |
NewerOlder