law:eval
List of: Scheme Extensions
Subjects: Analyzing Models, Laws
Contents: Kernel

Action: Evaluates a given law or law expression with the specified input and returns a real or list of reals.

Filename: kern/kern_scm/law_scm.cxx

Syntax: (law:eval law input)

Arg Types: law law | string | real | position |


par-pos | gvector

input (entity | entity ...) | real | gvector |


position | par-pos

Returns: real | (real ...)

Description: This Scheme extension evaluates the law at the given input value(s).


law can be a law Scheme type or a string enclosed by double quotation marks. law can be any combination of law functions. law can be multidimensional in domain and range. The vec law symbol can be used as part of the law definition to generate a multidimensional range (e.g., output is a list of reals).


input specifies the value(s) for evaluating the law.

Example: ; law:eval

; Create a new law.

(define law1 (law "x+x^2-cos(x)"))

;; law1

; Evaluate the given law at 1.5 radians

(law:eval law1 1.5)

;; 3.6792627983323

; Create a law with a multidimensional range.

(define mlaw (law "vec(x+2,x+3,x+4,x+5)"))

;; mlaw

(law:eval mlaw 3)

;; (5 6 7 8)

; Create a law with a multidimensional domain.

(define law2 (law "x^2 + y + z"))

;; law2

(law:eval law2 (list 2 3 4))

;; 11

(define law3 (law "a3^2 + a2 + a4"))

;; law3

; When evaluating this, the law function has 4 as its

; highest input index. Thus, the input list has to

; have at least four items. Input a1 is not used in

; the law function, so the first element of list

; is not used.

(law:eval law3 (list 1 2 3 4))

;; 15

; a3=3, a2=2, and a4=4. (a1=1).
PDF/KERN/14SCI.PDF
HTM/DATA/KERN/KERN/14SCI/0009.HTM