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
;;; | |
;;; http://d.hatena.ne.jp/ayato0211/20130221/1361438221 | |
;;; | |
;; ========= | |
;; quotation | |
;; ========= | |
(define (ok? ls) | |
(let ((model-1 (list-ref ls 0)) | |
(model-2 (list-ref ls 1)) | |
(model-3 (list-ref ls 2)) |
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 srfi-1) | |
(define (fizzbuzz) | |
(map | |
(lambda (x) | |
(cond | |
((zero? (modulo x 15)) "FizzBuzz") | |
((zero? (modulo x 5)) "Buzz") | |
((zero? (modulo x 3)) "Fizz") | |
(else x))) |
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 value-list '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\A #\B #\C #\D #\E #\F)) | |
;;10->16 | |
(define (decimal->hex n) | |
(let ((base 16)) | |
(let loop ((n n) | |
(o '())) | |
(cond | |
((zero? n) (list->string o)) | |
(else |
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 (baroque input) | |
(define (ok? ls) | |
(let ((model-1 (list-ref ls 0)) | |
(model-2 (list-ref ls 1)) | |
(model-3 (list-ref ls 2)) | |
(model-4 (list-ref ls 3))) | |
(and (= model-1 2) | |
(= model-2 3) | |
(= model-3 0) |
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
; 対応する括弧を表示する | |
(show-paren-mode t) | |
; デフォルトパスを~/にする | |
(cd "~/") | |
;起動するときに起動画面を表示しない | |
(setq inhibit-startup-message t) | |
; *.~ とかのバックアップファイルを作らない |
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 (expt-of-ten x) | |
(expt 10 x)) | |
(define (f c x) | |
(c x)) | |
(f expt-of-ten 2) |
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 (exp-of-ten x) | |
(expt 10 x)) | |
(define (foo x context) | |
(print (context x))) | |
(define (bar list context) | |
(for-each | |
(lambda (listp) (foo listp context)) |
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 (str-parse str) | |
(let loop ((ls (string->list str)) | |
(tmp-acc '()) | |
(acc '())) | |
(cond | |
((null? str) (reverse acc)) | |
(let ((c (car ls)) | |
(c2i (lambda (c) | |
(- (char->integer c) 48)))) | |
((or (char-whitespace? c) (null? (cdr ls))) |
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 (comp-tup tup) | |
(comp-tup-iter tup 0)) | |
(define (comp-tup-iter tup comp) | |
(define (pow a b) | |
(if (zero? b) | |
1 | |
(* a (pow a (- b 1))))) | |
(cond | |
((null? tup) comp) |
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 (str-count str) | |
(let loop ((ls (string->list str)) | |
(count 0)) | |
(let ((c (if (pair? ls) | |
(car ls) | |
ls)) | |
(inc (lambda (x) (+ x 1)))) | |
(cond | |
((null? ls) count) | |
((char-whitespace? c) (loop (cdr ls) count)) |