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
(map (lambda (f) | |
(f 5 5)) | |
(list * + - /)) | |
; -> (25 10 0 1) | |
(map (lambda (f) | |
(f 5 5)) | |
'(* + - /)) | |
; -> error |
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
;; member? | |
(define member? | |
(lambda (a lat) | |
(cond ((null? lat) #f) | |
((eq? a (car lat)) #t) | |
(else (member? a (cdr lat)))))) | |
(define member? | |
(lambda (a 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
;; 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 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
;; sum-of-prefixes | |
; (2 1 9 17 0) -> (2 3 12 29 29) | |
; (1 1 1 1 1) -> (1 2 3 4 5) | |
; letrec | |
(define sum-of-prefixes | |
(lambda (tup) |
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
テスト |
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
;; Gauche ユーザリファレンス: 10.2 srfi-1 - List library http://practical-scheme.net/gauche/man/gauche-refj_102.html#SEC310 | |
;; Making The Road Wiki - Programming::Scheme::SRFI1 http://ow.ly/13jo0 | |
;; fold | |
(fold + | |
0 | |
'(1 2 3 4 5)) | |
; -> 15 |
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
; fold, fold-right | |
(fold (lambda (x y z) | |
(display (format "x = ~a, y = ~a, z = ~a\n" x y z)) | |
(+ x y z)) 0 '(1 1 1) '(1 1 1)) | |
;; x = 1, y = 1, z = 0 | |
;; x = 1, y = 1, z = 2 | |
;; x = 1, y = 1, z = 4 | |
;; 6 | |
(fold (lambda (m n o r) |
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) | |
(lambda (n) | |
(if (zero? n) | |
1 | |
(* n ((f f)(- n 1)))))) | |
(lambda (f) | |
(lambda (n) | |
(if (zero? n) | |
1 | |
(* n ((f f)(- n 1))))))) 5) |
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
/* | |
(function (){ | |
alert('hello'); | |
})(); | |
*/ | |
var hello = function () { alert('hello')}; |
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 (collatz n) | |
(let ((stop (lambda (s) | |
(= s 1))) | |
(term (lambda (s) | |
(cond ((even? s)(/ s 2)) | |
((odd? s)(+ (* s 3) 1)) | |
(else s))))) | |
(unfold stop | |
(lambda (s) |