|
Action:
|
Makes a law that uses the times or multiplication ("*") operator.
|
|
|
Derivation:
|
times_law : binary_law : law : ACIS_OBJECT : -
|
|
|
Syntax:
|
my_law1 * my_law2
|
|
|
Description:
|
Parsing actually involves the "*" character.
my_law1 and
my_law2 can be any valid law. Both
my_law1 and
my_law2 can be multiple dimensions; the smaller of the two is padded with zeros.
|
|
|
The times law supports implied multiplication. This means that a constant (integer or real) placed in front of a variable and not already part of the previous variable is implied to be multiplication. The parser takes the longest recognizable string possible before determining implied multiplication. For example, "2XY" implies "2*X*Y", while "X2Y" implies "X2*Y". This facilitates entering equations in a more natural fashion, such as "2X^2+3.87Y+12Z^3" implies "2*(X^2)+(3.87)*(Y)+12*(Z^3)".
|
|
|
Example:
|
; law "*"
|
|
; Create a simple law.
|
|
(define my_firstlaw (law "x^2"))
|
|
;; my_firstlaw
|
|
; => #[law "X^2"]
|
|
; Create a second simple law.
|
|
(define my_secondlaw (law "x*3"))
|
|
;; my_secondlaw
|
|
; => #[law "X*3"]
|
|
; Create a third law that takes
|
|
; two laws as input arguments.
|
|
(define my_complexlaw
|
|
|
(law "law2-3*law1" my_firstlaw my_secondlaw))
|
|
;; my_complexlaw
|
|
; => #[law "X*3*3*X^2]
|
|
(law:eval my_complexlaw 2)
|
|
;; -6
|
|
|
; Create an input list to pass to the law.
|
|
(define my_list (list 1 2 3 4 5 6 7))
|
|
;; my_list
|
|
; Evaluate implied multiplication
|
|
(law:eval "yz" my_list)
|
|
;; 6
|
|
; Law parsing takes longest string possible
|
|
; before doing implied multiplication.
|
|
(law:eval "u4z" my_list)
|
|
;; 12
|
|
; Evaluate implied multiplication
|
|
(define my_law (law "a1b2c3d4e5f6Z7"))
|
|
;; my_law
|
|
; my_law => #[law "A1*B2*C3*D4*E5*F6*Z7"]
|
|
(law:eval my_law my_list)
|
|
;; 5040
|