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
((lambda (f) | |
(f f 10)) | |
(lambda (f n) | |
(if (< 0 n) | |
(begin | |
(print n) | |
(f f (- n 1)))))) | |
#| | |
10 | |
9 |
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 apply | |
(apply + (iota 10 1)) | |
;; use fold | |
(fold (lambda (n r) | |
(+ n r)) | |
0 | |
(iota 10 1)) | |
;; recursive recursion |
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 atom? | |
(lambda (x) | |
(and (not (pair? x)) | |
(not (null? x))))) | |
(define add1 | |
(lambda (n) | |
(+ n 1))) | |
(define sub1 |
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
(((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 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 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 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 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 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 insert-g | |
(lambda (set-f) | |
(lambda (new old lat) | |
(fold-right (lambda (e l) | |
(cond ((eq? old e)(set-f new old l)) | |
(else (cons e l)))) | |
'() | |
lat)))) |
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 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))))))) |
OlderNewer