! Copyright (C) 2009 Jason Merrill. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.functions math.dual assocs fry accessors ; IN: automatic-differentiation ! Replaces instances of math operators with their dual counterparts. This ! could be much smarter (work with nested quotations, inline word defs, etc.). ! If math operators could be overloaded like other generic words, there would ! be no need for this. : lift ( quot -- quot' ) H{ { + d+ } { - d- } { * d* } { / d/ } { ^ d^ } } substitute ; : [1diff] ( quot -- quot' ) lift '[ 1 @ epsilon-part>> ] ; : 1diff ( x quot -- y ) [1diff] call ; inline