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 atom? | |
(lambda (x) | |
(and (not (pair? x)) | |
(not (null? x))))) | |
(define add1 | |
(lambda (n) | |
(+ n 1))) | |
(define sub1 |
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
;; let loop | |
(let loop ((s 0)) | |
(if (< s 10) | |
(begin | |
(print "hello") | |
(loop (+ 1 s))))) | |
;; for-each | |
(use srfi-1) | |
(for-each |
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
(((lambda (f) | |
(f f)) | |
(lambda (f) | |
(lambda (n) | |
(if (<= n 100) | |
(begipn | |
(print (cond | |
((zero? (modulo n 15)) "FizzBuzz") | |
((zero? (modulo n 5)) "Buzz") | |
((zero? (modulo n 3)) "Fizz") |
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 fact | |
(lambda (n) | |
(if (zero? n) | |
1 | |
(* n (fact (- n 1)))))) | |
(fact 5) | |
;; apply | |
(use srfi-1) | |
(define fact |
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 9x9 | |
(lambda (row cnt inc mul) | |
(append | |
(cons | |
(map (lambda (n) | |
(cons (cons mul n)(cons (* n mul) '()))) | |
(iota cnt 1 inc)) | |
(if (zero? row) | |
'() |
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 combination | |
(lambda (r l) | |
(cond | |
((null? l) '()) | |
((or (zero? r)(> r (length l))) '()) | |
((= r 1)(map list l)) | |
((= r (length l))(list l)) | |
(else (append (map (lambda (n)(cons (car l) n)) | |
(combination (- r 1)(cdr l))) | |
(combination r (cdr l))))))) |
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 date->gmt | |
(lambda (date) | |
(let ((g (lambda (ls dl) | |
(string-join | |
(map (lambda (f) | |
(format #f "~2,,,'0,@a" (f date))) ls) dl)))) | |
(let ((yyyyMMdd (g (list date-year date-month date-day) "-")) | |
(hhmmdd (format #f "T~aZ" | |
(g (list date-hour date-minute date-second) ":")))) | |
(string-append yyyyMMdd hhmmdd))))) |
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 make-pad | |
(lambda (c len) | |
(lambda (n) | |
(format #f (string-append "~" (number->string len) ",,,'" c ",@a") n)))) |
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
(map (lambda (f) | |
(f 5 5)) | |
(list * + - /)) | |
; -> (25 10 0 1) | |
(map (lambda (f) | |
(f 5 5)) | |
'(* + - /)) | |
; -> error |
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
((lambda (f) | |
(f f 10)) | |
(lambda (f n) | |
(if (< 0 n) | |
(begin | |
(print n) | |
(f f (- n 1)))))) | |
#| | |
10 | |
9 |
OlderNewer