open symbolic math
show $ vdc 10s 12s
/*The result is:
"(0d + ((12d % 10d) / (1d * 10d))) + (((truncate (12d / 10d)) % 10d) / ((1d * 10d) * 10d))"
*/Sorry, I am afraid I have used a misleading term here. “symbolic” doesn’t evaluate calculations but instead represent all of them in the form of a graph. This graph is implemented through algebraic type and therefore can be pattern matched. So you can basically see the number of primitive operations and count them, e.g.:
open number symbolic math
calc 0u x = x
calc n x = calc (n - 1u) (x + 1u)
show $ calc 10s 12s ::: Sym
Output is:
(((((((((12d + 1d) + 1d) + 1d) + 1d) + 1d) + 1d) + 1d) + 1d) + 1d) + 1d
Not sure though that symbolic would do the job for you but you can take a look how symbolic is implemented. It is basically a custom number that (by default) doesn’t evaluate operations but instead constructs a graph (that can be evaluated later using ‘eval’ function). It can be a good starting point for your own numeric type.
--
---
You received this message because you are subscribed to the Google Groups "elalang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elalang+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.