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
(defvar *uncurry* nil "When bound and non-nil, curried functions can be uncurried") | |
(makunbound '*uncurry*) | |
(defun curry (function &rest args) | |
(lambda (&rest more-args) | |
(if (and (boundp '*uncurry*) *uncurry*) | |
(if more-args | |
(error "No more args expected") | |
function) | |
(apply function (append args more-args))))) |
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
(defun source-env-get (script &rest vars) | |
"Source script in shell, then look for vars in the resulting subshell environment" | |
(loop for line in (split-string (shell-command-to-string (concat "source " script " && set")) "[\n]" t) | |
with result | |
if (string-match "^\\([[:alpha:]]+\\)=\\(.*\\)$" line) | |
do (let ((var (match-string 1 line)) | |
(val (match-string 2 line))) | |
(when (or (not vars) (member var vars)) | |
(push (cons var val) result))) | |
finally return result)) |
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 macro: | |
(defmacro add-hook-one-time (hook function) | |
"Add FUNCTION to HOOK. Remove it after its first execution." | |
(let ((wrapper-function (make-symbol "wrapper-function-symbol"))) | |
`(progn | |
(defun ,wrapper-function () | |
"Wrapper function that will be executed only once, and then removed from the hook." | |
(funcall ,function) | |
(remove-hook ,hook ',wrapper-function)) | |
(add-hook ,hook ',wrapper-function)))) |
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
(let ((regex | |
(rx | |
(or bol bos) | |
(? (not (any "["))) | |
(group | |
(>= 2 (and (any "A-Z")(one-or-more (any "a-z"))))))) | |
case-fold-search) | |
(list | |
(replace-regexp-in-string regex "{\\1}" "[OneWordOrMore]") | |
(replace-regexp-in-string regex "{\\1}" "Onewordormore") |
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
(let ((regex | |
(rx | |
(or bol bos (not (any "["))) | |
(group | |
(>= 2 (and (any "A-Z")(one-or-more (any "a-z")))))))) | |
(list | |
(replace-regexp-in-string regex "\\1" "[OneWordOrMore]") | |
(replace-regexp-in-string regex "\\1" "Onewordormore") | |
(replace-regexp-in-string regex "\\1" "OneWordormore") | |
(replace-regexp-in-string regex "\\1" "OneWordOrMore"))) |
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 | |
// Define the 'class' class | |
$class = Obj() | |
->fn('new', function ($class) { | |
$newClass = Obj($class->methods) | |
->fn('new', function($class) { | |
$obj = Obj($class->imethods); | |
$args = func_get_args(); | |
array_shift($args); |