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 (yy-print fmt . args) | |
;; if Guile | |
(apply format #t fmt args) | |
;; if Racket | |
;;(apply printf fmt args) | |
) | |
(define (inc x) | |
;; if Guile | |
(1+ x) |
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 sets! | |
(syntax-rules () | |
((_ (var) (val)) | |
(set! var val)) | |
((_ (var vars* ...) (val vals* ...)) | |
(let ((var0 val)) | |
(sets! (vars* ...) (vals* ...)) | |
(set! var var0))))) |
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 (ice-9 rdelim) (rnrs)) | |
(define (k f init val pred) | |
(if (pred val) | |
init | |
(call-with-values (lambda () (f init val)) | |
(lambda (lst rst) (k f lst rst pred))))) | |
(define (lexer str delimiters) | |
(define (-> c) |
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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 (ice-9 rdelim))(define morse '((#\a ".-")(#\b "-...")(#\c "-.-.")(#\d "-..")(#\e ".")(#\f "..-.")(#\g "--.")(#\h "....")(#\i "..")(#\j ".---")(#\k "-.-")(#\l ".-..")(#\m "--")(\ | |
#\n "-.")(#\o "---")(#\p ".--.")(#\q "--.-")(#\r ".-.")(#\s "...")(#\t "-")(#\u "..-")(#\v "...-")(#\w ".--")(#\x "-.--")(#\y "-.--")(#\z "--..")))(for-each (lambda (x) (if (char-alphabetic\ | |
? x)(display (car (assoc-ref morse x))))(display " "))(string->list (string-downcase (read-line (current-input-port)))))(newline) |
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
#! /usr/local/bin/guile \ | |
-e main -s | |
!# | |
(define (main . args) | |
(let* ((ll ((@ (srfi srfi-1) iota) (read) 1)) (len (length ll)) (m (1- (/ len 2)))) | |
(display len)(newline) | |
(let lp((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1)) | |
(and (< n len) (for-each (lambda (x y) (display x)(display " ")(display y)(display " ")) a b)(newline) | |
(lp (append (list 1 (car b)) (cdr a)) (append (cdr b) (list (list-ref a m))) (1+ n)))))) |
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 (main . args) | |
(let* ((ll ((@ (srfi srfi-1) iota) (read) 1)) (len (length ll)) (m (1- (/ len 2)))) | |
(display len)(newline) | |
(let lp((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1)) | |
(and (< n len) (for-each (lambda (x y) (display x)(display " ")(display y)(display " ")) a b)(newline) | |
(lp `(1 ,(car b) ,@(cdr a)) `(,@(cdr b) ,(list-ref a m)) (1+ n)))))) |
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
#! /usr/local/bin/guile \ | |
-e main -s | |
!# | |
(define main | |
(lambda args | |
(let ((wrl (primitive-eval (read)))) | |
(for-each (lambda (x) | |
(format #t "[~a]:~%" (car x)) |
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
#!r6rs | |
;; a toy for turning srfi 28 format strings into a procedure, that | |
;; performs the format, and outputs to stdout | |
(library (toys srfi-28-compiler) | |
(export format-string->procedure) | |
(import (rnrs) | |
(only (srfi :1 lists) fold) | |
(srfi :8 receive)) | |
(define (escape-char? char) |
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
#! /usr/local/bin/guile \ | |
-e main -s | |
!# | |
(use-modules (ice-9 regex) (ice-9 ftw)) | |
(define (sub from to str) (regexp-substitute #f (string-match from str) 'pre to 'post)) | |
(define (usage args) (format #t "~a from to path~%" (car args))) | |
(define main |
OlderNewer