Created
March 9, 2015 16:23
-
-
Save jarcane/930466b881c100dea60a to your computer and use it in GitHub Desktop.
racket-mode encoding issue
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
#lang racket | |
(require math/number-theory) | |
(define Y (λ(b)((λ(f)(b(λ(x)((f f) x)))) | |
(λ(f)(b(λ(x)((f f) x))))))) | |
(define Fact | |
(Y (λ(fact) (λ(n) (if (zero? n) 1 (* n (fact (- n 1)))))))) | |
(define (classicfact n) | |
(if (zero? n) | |
1 | |
(* n (classicfact (sub1 n))))) | |
(define (k n (m 1)) | |
(if (<= n m) | |
n | |
(* (k n (* 2 m)) | |
(k (- n m) (* 2 m))))) | |
(time (void (Fact 10000))) | |
(time (void (classicfact 10000))) | |
(time (void (k 10000))) | |
(time (void (factorial 10000))) |
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
#lang racket | |
(require math/number-theory) | |
(define Y (λ(b)((λ(f)(b(λ(x)((f f) x)))) | |
(λ(f)(b(λ(x)((f f) x))))))) | |
(define Fact | |
(Y (λ(fact) (λ(n) (if (zero? n) 1 (* n (fact (- n 1)))))))) | |
(define (classicfact n) | |
(if (zero? n) | |
1 | |
(* n (classicfact (sub1 n))))) | |
(define (k n (m 1)) | |
(if (<= n m) | |
n | |
(* (k n (* 2 m)) | |
(k (- n m) (* 2 m))))) | |
(time (void (Fact 10000))) | |
(time (void (classicfact 10000))) | |
(time (void (k 10000))) | |
(time (void (factorial 10000))) |
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
#lang racket | |
(require math/number-theory) | |
(define Y (λ(b)((λ(f)(b(λ(x)((f f) x)))) | |
(λ(f)(b(λ(x)((f f) x))))))) | |
(define Fact | |
(Y (λ(fact) (λ(n) (if (zero? n) 1 (* n (fact (- n 1)))))))) | |
(define (classicfact n) | |
(if (zero? n) | |
1 | |
(* n (classicfact (sub1 n))))) | |
(define (k n (m 1)) | |
(if (<= n m) | |
n | |
(* (k n (* 2 m)) | |
(k (- n m) (* 2 m))))) | |
(time (void (Fact 10000))) | |
(time (void (classicfact 10000))) | |
(time (void (k 10000))) | |
(time (void (factorial 10000))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment