Skip to main content
added 228 characters in body
Source Link

Racket (scheme) 40 3535 29 bytes

Computes 0! to be 1, and computes 125! in 0 seconds according to timer. Regular recursive approach

(define(f n)(if(= n 0)1(* n(f(- n 1)))))

New version to beat common lisp: multiplies all elements of a list (same as that Haskell solution)

(λ(n)(apply *(build-list n add1)))

Newer version to beat the other scheme solution and math the other racket solution by using foldl instead of apply and using range instead of buildlist

(λ(n)(applyfoldl *(build-list n(range add11 n)))

Racket (scheme) 40 35 bytes

Computes 0! to be 1, and computes 125! in 0 seconds according to timer. Regular recursive approach

(define(f n)(if(= n 0)1(* n(f(- n 1)))))

New version to beat common lisp: multiplies all elements of a list (same as that Haskell solution)

(λ(n)(apply *(build-list n add1)))

Racket (scheme) 40 35 29 bytes

Computes 0! to be 1, and computes 125! in 0 seconds according to timer. Regular recursive approach

(define(f n)(if(= n 0)1(* n(f(- n 1)))))

New version to beat common lisp: multiplies all elements of a list (same as that Haskell solution)

(λ(n)(apply *(build-list n add1)))

Newer version to beat the other scheme solution and math the other racket solution by using foldl instead of apply and using range instead of buildlist

(λ(n)(foldl * n(range 1 n)))
added 214 characters in body
Source Link

Racket (scheme) 4040 35 bytes

Computes 0! to be 1, and computes 125! in 0 seconds according to timer. Regular recursive approach

(define(f n)(if(= n 0)1(* n(f(- n 1)))))

New version to beat common lisp: multiplies all elements of a list (same as that Haskell solution)

(defineλ(f n)(if(= napply 0)1(* n(f(build-list n 1))add1)))

Racket (scheme) 40 bytes

Computes 0! to be 1, and computes 125! in 0 seconds according to timer.

(define(f n)(if(= n 0)1(* n(f(- n 1)))))

Racket (scheme) 40 35 bytes

Computes 0! to be 1, and computes 125! in 0 seconds according to timer. Regular recursive approach

(define(f n)(if(= n 0)1(* n(f(- n 1)))))

New version to beat common lisp: multiplies all elements of a list (same as that Haskell solution)

(λ(n)(apply *(build-list n add1)))
Source Link

Racket (scheme) 40 bytes

Computes 0! to be 1, and computes 125! in 0 seconds according to timer.

(define(f n)(if(= n 0)1(* n(f(- n 1)))))