 
 : (gamma-lanczos6) ( x -- log[gamma[x+1]] )
     #! log(gamma(x+1)
-    [ 0.5 + dup gamma-g6 + dup [ log * ] dip - ]
+    [ 0.5 + dup gamma-g6 + [ log * ] keep - ]
     [ 6 gamma-z gamma-p6 v. log ] bi + ;
 
 : gamma-lanczos6 ( x -- gamma[x] )
     #! gamma(x) = gamma(x+1) / x
-    dup (gamma-lanczos6) exp swap / ;
+    [ (gamma-lanczos6) exp ] keep / ;
 
 : gammaln-lanczos6 ( x -- gammaln[x] )
     #! log(gamma(x)) = log(gamma(x+1)) - log(x)
-    dup (gamma-lanczos6) swap log - ;
+    [ (gamma-lanczos6) ] keep log - ;
 
 : gamma-neg ( gamma[abs[x]] x -- gamma[x] )
     dup pi * sin * * pi neg swap / ; inline

! Copyright (C) 2008 Doug Coleman, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.constants math.functions math.intervals
math.vectors namespaces sequences combinators.short-circuit ;
IN: math.analysis

<PRIVATE


: stirling-fact ( n -- fact )
    [ pi 2 * * sqrt ]
    [ [ e / ] keep ^ ]
    [ 12 * recip 1+ ] tri * * ;

