Skip to content

Commit

Permalink
math.factorials: implement "undo" for factorials.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Nov 30, 2016
1 parent 1e2e2dc commit 8bdaf26
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions extra/math/factorials/factorials.factor
@@ -1,8 +1,8 @@
! Copyright (C) 2013 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: combinators combinators.short-circuit fry kernel math
math.functions math.primes math.ranges memoize sequences ;
USING: combinators combinators.short-circuit fry inverse kernel
math math.functions math.primes math.ranges memoize sequences ;

IN: math.factorials

Expand Down Expand Up @@ -121,3 +121,7 @@ PRIVATE>

: reverse-factorial ( m -- n )
1 1 [ 2over > ] [ 1 + [ * ] keep ] while [ = ] dip and ;

\ factorial [ reverse-factorial ] define-inverse

\ reverse-factorial [ factorial ] define-inverse

0 comments on commit 8bdaf26

Please sign in to comment.