1 ! Copyright (C) 2005, 2009 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: xml io kernel math sequences strings xml.utilities
4 tools.test math.parser xml.dispatch ;
7 PROCESS: calculate ( tag -- n )
9 : calc-2children ( tag -- n n )
10 children-tags first2 [ calculate ] dip calculate ;
13 children>string string>number ;
23 children-tags first calculate neg ;
25 : calc-arith ( string -- n )
26 string>xml first-child-tag calculate ;
29 "<math><times><add><number>1</number><number>3</number></add><neg><number>-8</number></neg></times></math>"