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
void sly_io_write_c_string(sly_state_t *S, const char* s, sly_oport_t *port) | |
{ | |
const char *p; | |
for(p = s; p; p++) { | |
port_write_char(S, port, (sly_char_t)*p); | |
} | |
} |
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
;; hypothetical Scheme web DSL | |
;; note that the macro binds the URI variables | |
;; to local variables | |
(GET "/api/show/:user/:repo" | |
(if (user-has-repo? user repo) | |
(render-repo-xml user repo) | |
...)) |
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
(define (legal? move player board) | |
(and (eqv? (board-ref board move) *empty*) | |
(any? (lambda (dir) | |
(would-flip move player board dir)) | |
*all-directions*))) |
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* ((ser (with-input-from-file "state.scm" | |
(lambda () (read)))) | |
(obj (u8vector->object ser))) | |
(cond | |
((game-state? obj | |
obj) | |
((game-state-1? obj) | |
(game-state-from-v1 obj)) | |
((game-state-2? obj) | |
(game-state-from-v2 obj)) |
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
;; made tail-recursive | |
;; constant stack use | |
(define (file-lines file) | |
(call-with-input-file file | |
(lambda (port) | |
(let loop ([line (read-line port)] | |
[l '()]) | |
(if (eof-object? line) (reverse l) | |
(loop (read-line port) (cons line l))))))) |
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
(define-syntax define-page | |
(syntax-rules () | |
((_ name title headers body ...) (define (name #!rest params) | |
(let* ([post-data (process-request)] | |
[form-data (if post-data | |
(append post-data | |
params) | |
params)]) | |
(html-body name | |
(lambda () |
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
> (##expand-code '(or temp (let ((temp (* 2 3))) (and alex temp)))) | |
((lambda (tempv1) | |
(if tempv1 | |
tempv1 | |
((lambda (tempv2) ((lambda (tempv3) (if tempv3 tempv2 tempv3)) alex)) | |
(* '2 '3)))) | |
temp) |
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
;; joins two consecutives lines like vim's "J" | |
(defun join-lines () | |
(interactive) | |
(save-excursion | |
(end-of-line) | |
(insert-char ? 1) | |
(delete-char 1) | |
(while (looking-at "\\s +") | |
(delete-char 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
;;; NQUEENS -- Compute number of solutions to 8-queens problem. | |
(define (nqueens n) | |
(define (dec-to n) | |
(let loop ((i n) (l '())) | |
(if (= i 0) l (loop (- i 1) (cons i l))))) | |
(define (try x y z) | |
(if (null? x) | |
(if (null? y) | |
1 | |
0) |
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
POVRAY = povray | |
CONVERT = convert | |
ifeq ($(BASE),) | |
BASE = board | |
endif | |
ifeq ($(TYPE),) | |
TYPE = tiff | |
endif |
OlderNewer